mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| faaa56eda6 | |||
| 4b54a00d89 | |||
| 00955f0ac5 |
@@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"src": {
|
"src": {
|
||||||
"@typescript-eslint/no-non-null-assertion": 345,
|
"@typescript-eslint/no-non-null-assertion": 338,
|
||||||
"@typescript-eslint/no-misused-promises": 810,
|
"@typescript-eslint/no-misused-promises": 750,
|
||||||
"no-console": 85,
|
"no-console": 81,
|
||||||
"complexity": 214,
|
"complexity": 214,
|
||||||
"@typescript-eslint/no-explicit-any": 113,
|
"@typescript-eslint/no-explicit-any": 113,
|
||||||
"trek/no-swallowed-catch": 124,
|
"trek/no-swallowed-catch": 124,
|
||||||
"max-params": 31,
|
"max-params": 31,
|
||||||
"trek/store-without-selector": 65,
|
"trek/store-without-selector": 65,
|
||||||
"react-hooks/refs": 384,
|
"react-hooks/refs": 380,
|
||||||
"react-hooks/set-state-in-effect": 188,
|
"react-hooks/set-state-in-effect": 188,
|
||||||
"@typescript-eslint/no-floating-promises": 162,
|
"@typescript-eslint/no-floating-promises": 156,
|
||||||
"react-hooks/exhaustive-deps": 112,
|
"react-hooks/exhaustive-deps": 112,
|
||||||
"@typescript-eslint/no-unused-vars": 95,
|
"@typescript-eslint/no-unused-vars": 95,
|
||||||
"react-hooks/immutability": 26,
|
"react-hooks/immutability": 26,
|
||||||
"max-lines-per-function": 126,
|
"max-lines-per-function": 126,
|
||||||
"react-hooks/static-components": 38,
|
"react-hooks/static-components": 35,
|
||||||
"react-hooks/preserve-manual-memoization": 12,
|
"react-hooks/preserve-manual-memoization": 12,
|
||||||
"no-useless-assignment": 7,
|
"no-useless-assignment": 7,
|
||||||
"no-empty": 18,
|
"no-empty": 18,
|
||||||
|
|||||||
@@ -227,7 +227,11 @@
|
|||||||
"src/pages/sharedTrip/SharedBookingsView.tsx",
|
"src/pages/sharedTrip/SharedBookingsView.tsx",
|
||||||
"src/pages/sharedTrip/SharedDayCard.tsx"
|
"src/pages/sharedTrip/SharedDayCard.tsx"
|
||||||
],
|
],
|
||||||
"mobile": ["src/mobile/screens/trip/tabs/MBookingsTab.tsx", "src/mobile/screens/trip/tabs/MTransportsTab.tsx"]
|
"mobile": [
|
||||||
|
"src/mobile/screens/trip/tabs/MBookingsTab.tsx",
|
||||||
|
"src/mobile/screens/trip/tabs/MTransportsTab.tsx",
|
||||||
|
"src/mobile/screens/trip/MItineraryBookingCard.tsx"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"feature": "Bottom nav context-aware create action",
|
"feature": "Bottom nav context-aware create action",
|
||||||
@@ -267,6 +271,12 @@
|
|||||||
"desktop": ["src/components/Collab/useCollabChat.ts"],
|
"desktop": ["src/components/Collab/useCollabChat.ts"],
|
||||||
"mobile": ["src/mobile/screens/trip/tabs/MCollabChat.tsx"]
|
"mobile": ["src/mobile/screens/trip/tabs/MCollabChat.tsx"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"feature": "Collab links",
|
||||||
|
"hooks": ["src/components/Collab/useCollabLinks.ts"],
|
||||||
|
"desktop": ["src/components/Collab/CollabLinks.tsx"],
|
||||||
|
"mobile": ["src/mobile/screens/trip/tabs/MCollabLinks.tsx"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"feature": "Collab notes",
|
"feature": "Collab notes",
|
||||||
"hooks": ["src/components/Collab/useCollabNotesData.ts"],
|
"hooks": ["src/components/Collab/useCollabNotesData.ts"],
|
||||||
@@ -398,7 +408,7 @@
|
|||||||
"src/mobile/screens/collections/MCollEditSheet.tsx",
|
"src/mobile/screens/collections/MCollEditSheet.tsx",
|
||||||
"src/mobile/screens/collections/MCollPlaceRow.tsx",
|
"src/mobile/screens/collections/MCollPlaceRow.tsx",
|
||||||
"src/mobile/screens/collections/MCollPlaceSheet.tsx",
|
"src/mobile/screens/collections/MCollPlaceSheet.tsx",
|
||||||
"src/mobile/screens/collections/MCollections.tsx"
|
"src/mobile/screens/collections/MCollSavedFilters.tsx"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -438,7 +448,7 @@
|
|||||||
"feature": "Costs/budget splitting or totals only: useCostsMode",
|
"feature": "Costs/budget splitting or totals only: useCostsMode",
|
||||||
"hooks": ["src/components/Budget/useCostsMode.ts"],
|
"hooks": ["src/components/Budget/useCostsMode.ts"],
|
||||||
"desktop": ["src/components/Budget/CostsModeCard.tsx"],
|
"desktop": ["src/components/Budget/CostsModeCard.tsx"],
|
||||||
"mobile": ["src/mobile/screens/trip/tabs/MCostsTab.tsx"]
|
"mobile": ["src/mobile/screens/trip/sheets/MTripSettingsSheet.tsx"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"feature": "Costs/budget settle-up payment: useSettlementForm",
|
"feature": "Costs/budget settle-up payment: useSettlementForm",
|
||||||
@@ -600,10 +610,8 @@
|
|||||||
"src/pages/journeyPublic/useJourneyPublic.ts"
|
"src/pages/journeyPublic/useJourneyPublic.ts"
|
||||||
],
|
],
|
||||||
"mobile": [
|
"mobile": [
|
||||||
"src/mobile/screens/journey/MJourneyCreateSheet.tsx",
|
|
||||||
"src/mobile/screens/journey/MJourneyDetail.tsx",
|
"src/mobile/screens/journey/MJourneyDetail.tsx",
|
||||||
"src/mobile/screens/journey/MJourneyEntrySheet.tsx",
|
"src/mobile/screens/journey/MJourneyEntrySheet.tsx",
|
||||||
"src/mobile/screens/journey/MJourneySettingsSheet.tsx",
|
|
||||||
"src/mobile/screens/journey/mobileJourneyMeta.ts"
|
"src/mobile/screens/journey/mobileJourneyMeta.ts"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -864,12 +872,6 @@
|
|||||||
"desktop": ["src/components/Roadtrip/RoadtripStopPopup.tsx"],
|
"desktop": ["src/components/Roadtrip/RoadtripStopPopup.tsx"],
|
||||||
"mobile": ["src/mobile/screens/trip/roadtrip/MRtDraftSheet.tsx"]
|
"mobile": ["src/mobile/screens/trip/roadtrip/MRtDraftSheet.tsx"]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"feature": "Road-trip Google Maps route import",
|
|
||||||
"hooks": ["src/components/Roadtrip/useGoogleRouteImport.ts"],
|
|
||||||
"desktop": ["src/components/Roadtrip/GoogleRouteImport.tsx"],
|
|
||||||
"mobile": ["src/mobile/screens/trip/roadtrip/MRtRouteImportSheet.tsx"]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"feature": "Road-trip stay length draft",
|
"feature": "Road-trip stay length draft",
|
||||||
"hooks": ["src/components/Roadtrip/useStayDraft.ts"],
|
"hooks": ["src/components/Roadtrip/useStayDraft.ts"],
|
||||||
@@ -1059,11 +1061,13 @@
|
|||||||
"src/components/Planner/ReservationsPanel.tsx",
|
"src/components/Planner/ReservationsPanel.tsx",
|
||||||
"src/components/Planner/bookings/BookingDetailHost.tsx"
|
"src/components/Planner/bookings/BookingDetailHost.tsx"
|
||||||
],
|
],
|
||||||
"mobile": [
|
"mobile": ["src/mobile/screens/trip/sheets/MTransportSheet.tsx"]
|
||||||
"src/mobile/screens/trip/sheets/MTransportSheet.tsx",
|
},
|
||||||
"src/mobile/screens/trip/tabs/MBookingsTab.tsx",
|
{
|
||||||
"src/mobile/screens/trip/tabs/MTransportsTab.tsx"
|
"feature": "Transit itinerary facts and note formatting",
|
||||||
]
|
"hooks": ["src/components/Planner/transitJourneyModel.ts"],
|
||||||
|
"desktop": ["src/components/Planner/TransitJourneyModal.tsx"],
|
||||||
|
"mobile": ["src/mobile/screens/trip/sheets/MTransitJourneySheet.tsx"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"feature": "Transport booking detail view: transportDetailModel",
|
"feature": "Transport booking detail view: transportDetailModel",
|
||||||
@@ -1234,6 +1238,7 @@
|
|||||||
"src/mobile/screens/collections/collectionsMobileModel.ts": "Visual constants only the phone collections screens use (category and status specs, swatches, cover gradient).",
|
"src/mobile/screens/collections/collectionsMobileModel.ts": "Visual constants only the phone collections screens use (category and status specs, swatches, cover gradient).",
|
||||||
"src/mobile/screens/dashboard/MUserMenu.tsx": "Phone avatar menu with a three state theme cycle the desktop navbar does not have.",
|
"src/mobile/screens/dashboard/MUserMenu.tsx": "Phone avatar menu with a three state theme cycle the desktop navbar does not have.",
|
||||||
"src/mobile/screens/journey/MDawarichDaySheet.tsx": "Markup only; the phone frame the Dawarich day sheets (route and stays) render their shared review in.",
|
"src/mobile/screens/journey/MDawarichDaySheet.tsx": "Markup only; the phone frame the Dawarich day sheets (route and stays) render their shared review in.",
|
||||||
|
"src/mobile/screens/journey/MJourneyCreateSheet.tsx": "The phone form receives the journey and trip selection state from MJourney, which shares useJourney with the desktop list.",
|
||||||
"src/mobile/screens/journey/MJourneyFeed.tsx": "Markup only; the journey's entries as a feed beside the map on a wide window, with the entries, the active one and the tap handed in through props from useJourneyDetail and useJourneyCarouselSync.",
|
"src/mobile/screens/journey/MJourneyFeed.tsx": "Markup only; the journey's entries as a feed beside the map on a wide window, with the entries, the active one and the tap handed in through props from useJourneyDetail and useJourneyCarouselSync.",
|
||||||
"src/mobile/screens/settings/MAppLockCard.tsx": "Phone only: the app lock exists only in the native app, so there is no desktop setting to share with.",
|
"src/mobile/screens/settings/MAppLockCard.tsx": "Phone only: the app lock exists only in the native app, so there is no desktop setting to share with.",
|
||||||
"src/mobile/screens/settings/MClientCertCard.tsx": "Phone only: the client certificate is kept by the native app, so there is no desktop setting to share with.",
|
"src/mobile/screens/settings/MClientCertCard.tsx": "Phone only: the client certificate is kept by the native app, so there is no desktop setting to share with.",
|
||||||
@@ -1252,7 +1257,26 @@
|
|||||||
"src/mobile/screens/trip/MTripShellParts.tsx": "Markup only; small pieces of MTripShell's top controls (segment pill, compact toggle, document sync button), with the state and handlers MTripShell hands in.",
|
"src/mobile/screens/trip/MTripShellParts.tsx": "Markup only; small pieces of MTripShell's top controls (segment pill, compact toggle, document sync button), with the state and handlers MTripShell hands in.",
|
||||||
"src/mobile/screens/trip/dockTabs.ts": "Phone only helper that picks which trip tabs get a seat in the mobile dock.",
|
"src/mobile/screens/trip/dockTabs.ts": "Phone only helper that picks which trip tabs get a seat in the mobile dock.",
|
||||||
"src/mobile/screens/trip/useTripTabSwitch.ts": "Phone shell only; switches the section the dock and a notification link open, and the collab part a message link means. The desktop switches through useTripPlanner alone.",
|
"src/mobile/screens/trip/useTripTabSwitch.ts": "Phone shell only; switches the section the dock and a notification link open, and the collab part a message link means. The desktop switches through useTripPlanner alone.",
|
||||||
"src/mobile/screens/trip/lib/dayNotes.ts": "Phone only helper that splits a leading time off a day note for the plan timeline.",
|
"src/mobile/screens/collections/MCollColorSwatches.tsx": "Shared color chooser for the phone list and tag forms.",
|
||||||
|
"src/mobile/screens/collections/MCollPlaceFields.tsx": "Shared layout of the nullable category, address and description fields in phone add and edit forms.",
|
||||||
|
"src/mobile/screens/collections/MCollToolbar.tsx": "Search, view and filter controls shared by the two phone collection lists.",
|
||||||
|
"src/mobile/screens/journey/MJourneyInviteFrame.tsx": "Phone invitation layout over the shared ContributorInviteDialog controller.",
|
||||||
|
"src/mobile/screens/journey/MJourneyEntryRead.tsx": "Phone journal reader over the shared markdown, photo and entry title models.",
|
||||||
|
"src/mobile/screens/journey/MJourneyVerdict.tsx": "Phone verdict layout shared by the reader and the editor; writes use the shared journey entry form.",
|
||||||
|
"src/mobile/screens/trip/map/MMapExplore.tsx": "Phone entry points and panels for the shared map exploration state.",
|
||||||
|
"src/mobile/screens/trip/map/MMapPlaceFilters.tsx": "Phone sheet presenting map and place visibility controls.",
|
||||||
|
"src/mobile/screens/trip/roadtrip/MRtChoice.tsx": "Phone grid option for the Roadtrip corridor sheets.",
|
||||||
|
"src/mobile/screens/trip/roadtrip/stageBookings.ts": "Places bookings and their approaches within the phone stage timeline using the shared Roadtrip router and stop associations.",
|
||||||
|
"src/mobile/screens/trip/sheets/MBookingImportSheet.tsx": "Phone presentation passed to the shared booking import controller.",
|
||||||
|
"src/mobile/screens/trip/sheets/MDayPickerSheet.tsx": "Searchable phone day picker, separate from the desktop day sidebar.",
|
||||||
|
"src/mobile/screens/trip/sheets/MGpxPreviewFrame.tsx": "Phone GPX preview layout over the shared TourGpxPreviewDialog controller.",
|
||||||
|
"src/mobile/screens/trip/sheets/MIcsSubscribeSheet.tsx": "Phone form for the shared calendar subscription hook.",
|
||||||
|
"src/mobile/screens/trip/sheets/MSubscribeLinks.tsx": "Phone provider and link actions for the shared subscription links hook.",
|
||||||
|
"src/mobile/screens/trip/sheets/MTripOfflinePage.tsx": "Trip-specific offline controls in the phone settings.",
|
||||||
|
"src/mobile/screens/trip/useMTripDayResume.ts": "Restores the last day in the phone's single-day planner.",
|
||||||
|
"src/mobile/screens/trip/tabs/MChecklistCheck.tsx": "Phone checkbox controls shared by trip tasks and packing.",
|
||||||
|
"src/mobile/screens/trip/sheets/MCurrencyPicker.tsx": "Searchable mobile currency picker shared by the dashboard and costs ledger.",
|
||||||
|
"src/mobile/screens/trip/tabs/MReservationList.tsx": "Shared phone shell for the bookings and transport tabs.",
|
||||||
"src/mobile/screens/trip/map/MMapArea.tsx": "Phone map stage framing; already shares usePoiExplore and useMergedMapPois with the desktop trip planner.",
|
"src/mobile/screens/trip/map/MMapArea.tsx": "Phone map stage framing; already shares usePoiExplore and useMergedMapPois with the desktop trip planner.",
|
||||||
"src/mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx": "Markup only; categories and the pick handler come through props from MPlacesBrowser.",
|
"src/mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx": "Markup only; categories and the pick handler come through props from MPlacesBrowser.",
|
||||||
"src/mobile/screens/trip/places/MPlacesToursModeSwitch.tsx": "Markup only places or tours toggle; value and onChange come through props from MPlacesBrowser.",
|
"src/mobile/screens/trip/places/MPlacesToursModeSwitch.tsx": "Markup only places or tours toggle; value and onChange come through props from MPlacesBrowser.",
|
||||||
@@ -1288,7 +1312,7 @@
|
|||||||
"src/mobile/screens/trip/sheets/PlTags.tsx": "Markup only; the tag picker's state comes through props from MPlaceEditSheet, which runs usePlaceTags, and the chips of the place sheet draw the tags the place carries.",
|
"src/mobile/screens/trip/sheets/PlTags.tsx": "Markup only; the tag picker's state comes through props from MPlaceEditSheet, which runs usePlaceTags, and the chips of the place sheet draw the tags the place carries.",
|
||||||
"src/mobile/screens/trip/sheets/PlTimeFields.tsx": "Phone time fields that already share timeCollisions with the desktop PlaceFormModal.",
|
"src/mobile/screens/trip/sheets/PlTimeFields.tsx": "Phone time fields that already share timeCollisions with the desktop PlaceFormModal.",
|
||||||
"src/mobile/screens/trip/sheets/tourSheetOpen.ts": "Phone only context for MTourDetailShell: whether the tour sheet is open and the name it carries.",
|
"src/mobile/screens/trip/sheets/tourSheetOpen.ts": "Phone only context for MTourDetailShell: whether the tour sheet is open and the name it carries.",
|
||||||
"src/mobile/screens/trip/tabs/MCollabTab.tsx": "Phone collab sub tab router that reuses the desktop CollabLinks component.",
|
"src/mobile/screens/trip/tabs/MCollabTab.tsx": "Phone collab sub-tab router for the chat and boards.",
|
||||||
"src/mobile/screens/trip/tabs/MFilesBoard.tsx": "Markup only; the trip's files as tiles and the picked file's preview on a wide window, with the files and their actions handed in through props from MFilesTab.",
|
"src/mobile/screens/trip/tabs/MFilesBoard.tsx": "Markup only; the trip's files as tiles and the picked file's preview on a wide window, with the files and their actions handed in through props from MFilesTab.",
|
||||||
"src/mobile/screens/trip/tabs/MListsTab.tsx": "Phone router between the packing and to-do bodies, with no logic of its own.",
|
"src/mobile/screens/trip/tabs/MListsTab.tsx": "Phone router between the packing and to-do bodies, with no logic of its own.",
|
||||||
"src/mobile/screens/trip/tabs/MPackingCategorySharingSheet.tsx": "Markup only; the sheet that shares a whole list, with its state from usePackingCategorySharing handed in through props by MPackingListTab.",
|
"src/mobile/screens/trip/tabs/MPackingCategorySharingSheet.tsx": "Markup only; the sheet that shares a whole list, with its state from usePackingCategorySharing handed in through props by MPackingListTab.",
|
||||||
|
|||||||
@@ -1330,7 +1330,6 @@
|
|||||||
"src/mobile/screens/trip/MTripShell.tsx",
|
"src/mobile/screens/trip/MTripShell.tsx",
|
||||||
"src/mobile/screens/trip/dockTabs.test.ts",
|
"src/mobile/screens/trip/dockTabs.test.ts",
|
||||||
"src/mobile/screens/trip/dockTabs.ts",
|
"src/mobile/screens/trip/dockTabs.ts",
|
||||||
"src/mobile/screens/trip/lib/dayNotes.ts",
|
|
||||||
"src/mobile/screens/trip/map/MMapArea.tsx",
|
"src/mobile/screens/trip/map/MMapArea.tsx",
|
||||||
"src/mobile/screens/trip/places/MPlacesBrowser.tsx",
|
"src/mobile/screens/trip/places/MPlacesBrowser.tsx",
|
||||||
"src/mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx",
|
"src/mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx",
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
{
|
{
|
||||||
"admin.ts": 112,
|
"admin.ts": 112,
|
||||||
"atlas.ts": 7,
|
"atlas.ts": 6,
|
||||||
"backup.ts": 10,
|
"backup.ts": 10,
|
||||||
"budget.ts": 35,
|
"budget.ts": 35,
|
||||||
"categories.ts": 1,
|
"categories.ts": 1,
|
||||||
"collab.ts": 9,
|
"collab.ts": 9,
|
||||||
"collection.ts": 29,
|
"collection.ts": 27,
|
||||||
"common.ts": 6,
|
"common.ts": 6,
|
||||||
"dashboard.ts": 64,
|
"dashboard.ts": 60,
|
||||||
"dawarich.ts": 15,
|
"dawarich.ts": 15,
|
||||||
"dayplan.ts": 17,
|
"dayplan.ts": 17,
|
||||||
"docsync.ts": 25,
|
"docsync.ts": 25,
|
||||||
"files.ts": 4,
|
"files.ts": 4,
|
||||||
"help.ts": 3,
|
"help.ts": 3,
|
||||||
"inspector.ts": 4,
|
"inspector.ts": 4,
|
||||||
"journey.ts": 65,
|
"journey.ts": 64,
|
||||||
"login.ts": 1,
|
"login.ts": 1,
|
||||||
"map.ts": 5,
|
"map.ts": 5,
|
||||||
"memories.ts": 8,
|
"memories.ts": 8,
|
||||||
"mobileNav.ts": 2,
|
"mobileNav.ts": 2,
|
||||||
"mobileVacay.ts": 4,
|
|
||||||
"nav.ts": 1,
|
"nav.ts": 1,
|
||||||
"notif.ts": 7,
|
"notif.ts": 7,
|
||||||
"notifications.ts": 17,
|
"notifications.ts": 17,
|
||||||
@@ -27,10 +26,10 @@
|
|||||||
"pdf.ts": 1,
|
"pdf.ts": 1,
|
||||||
"perm.ts": 4,
|
"perm.ts": 4,
|
||||||
"places.ts": 9,
|
"places.ts": 9,
|
||||||
"planner.ts": 52,
|
"planner.ts": 49,
|
||||||
"reservations.ts": 21,
|
"reservations.ts": 20,
|
||||||
"roadtrip.ts": 36,
|
"roadtrip.ts": 36,
|
||||||
"settings.ts": 37,
|
"settings.ts": 36,
|
||||||
"share.ts": 7,
|
"share.ts": 7,
|
||||||
"shared.ts": 2,
|
"shared.ts": 2,
|
||||||
"storage.ts": 16,
|
"storage.ts": 16,
|
||||||
|
|||||||
@@ -28,8 +28,6 @@
|
|||||||
"src/components/Journey/MobileEntryView.tsx": 1,
|
"src/components/Journey/MobileEntryView.tsx": 1,
|
||||||
"src/components/Map/MapView.tsx": 1,
|
"src/components/Map/MapView.tsx": 1,
|
||||||
"src/components/Map/MapViewGL.tsx": 1,
|
"src/components/Map/MapViewGL.tsx": 1,
|
||||||
"src/components/Planner/IcsSubscribeModal.tsx": 1,
|
|
||||||
"src/components/Planner/TransitJourneyModal.tsx": 1,
|
|
||||||
"src/components/Planner/TransitSearchPanel.tsx": 1,
|
"src/components/Planner/TransitSearchPanel.tsx": 1,
|
||||||
"src/components/Planner/TripWarningsBanner.tsx": 1,
|
"src/components/Planner/TripWarningsBanner.tsx": 1,
|
||||||
"src/components/Planner/transitDisplay.tsx": 1,
|
"src/components/Planner/transitDisplay.tsx": 1,
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
"src/components/Budget/ReceiptPreviewModal.tsx",
|
"src/components/Budget/ReceiptPreviewModal.tsx",
|
||||||
"src/components/Budget/receiptUploads.ts",
|
"src/components/Budget/receiptUploads.ts",
|
||||||
"src/components/Collab/CollabChatLinkPreview.tsx",
|
"src/components/Collab/CollabChatLinkPreview.tsx",
|
||||||
"src/components/Collab/CollabLinks.tsx",
|
|
||||||
"src/components/Collab/CollabNotes.tsx",
|
"src/components/Collab/CollabNotes.tsx",
|
||||||
"src/components/Collab/CollabNotesAuthedImg.tsx",
|
"src/components/Collab/CollabNotesAuthedImg.tsx",
|
||||||
"src/components/Collab/CollabNotesFilePreviewPortal.tsx",
|
"src/components/Collab/CollabNotesFilePreviewPortal.tsx",
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
"components/Journey/JourneyDetailPageGalleryView.tsx": 1,
|
"components/Journey/JourneyDetailPageGalleryView.tsx": 1,
|
||||||
"components/Journey/JourneyDetailPagePhotoGrid.tsx": 1,
|
"components/Journey/JourneyDetailPagePhotoGrid.tsx": 1,
|
||||||
"components/Journey/JourneyDetailPageProviderPicker.tsx": 1,
|
"components/Journey/JourneyDetailPageProviderPicker.tsx": 1,
|
||||||
"components/Journey/JourneyEntryCover.tsx": 1,
|
|
||||||
"components/Journey/JourneyMap.tsx": 1,
|
"components/Journey/JourneyMap.tsx": 1,
|
||||||
"components/Journey/JourneyMapGL.tsx": 2,
|
"components/Journey/JourneyMapGL.tsx": 2,
|
||||||
"components/Journey/MobileEntryView.tsx": 1,
|
"components/Journey/MobileEntryView.tsx": 1,
|
||||||
@@ -76,7 +75,7 @@
|
|||||||
"hooks/useAnchoredPosition.ts": 3,
|
"hooks/useAnchoredPosition.ts": 3,
|
||||||
"hooks/useElementRect.ts": 3,
|
"hooks/useElementRect.ts": 3,
|
||||||
"mobile/components/MSegmented.tsx": 1,
|
"mobile/components/MSegmented.tsx": 1,
|
||||||
"mobile/screens/journey/MJourneyDetail.tsx": 3,
|
"mobile/screens/journey/MJourneyDetail.tsx": 2,
|
||||||
"mobile/screens/journey/MJourneyEntrySheet.tsx": 1,
|
"mobile/screens/journey/MJourneyEntrySheet.tsx": 1,
|
||||||
"mobile/screens/trip/map/MMapArea.tsx": 3,
|
"mobile/screens/trip/map/MMapArea.tsx": 3,
|
||||||
"mobile/screens/trip/tabs/MFileLightbox.tsx": 2,
|
"mobile/screens/trip/tabs/MFileLightbox.tsx": 2,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"components/Studio/LineHandles.tsx": 1,
|
"components/Studio/LineHandles.tsx": 1,
|
||||||
"components/Studio/StudioSelectionChrome.tsx": 2,
|
"components/Studio/StudioSelectionChrome.tsx": 2,
|
||||||
"components/Studio/inspector/FocalPad.tsx": 1,
|
"components/Studio/inspector/FocalPad.tsx": 1,
|
||||||
|
"components/Tours/TourGpxPreviewDialog.tsx": 1,
|
||||||
"mobile/components/trek3d/MascotClip.tsx": 1,
|
"mobile/components/trek3d/MascotClip.tsx": 1,
|
||||||
"mobile/screens/trip/MTripShell.tsx": 1,
|
"mobile/screens/trip/MTripShell.tsx": 1,
|
||||||
"mobile/screens/vacay/MVacay.tsx": 1,
|
"mobile/screens/vacay/MVacay.tsx": 1,
|
||||||
|
|||||||
@@ -96,7 +96,6 @@
|
|||||||
"src/hooks/useDawarichSuggestions.test.ts": 1,
|
"src/hooks/useDawarichSuggestions.test.ts": 1,
|
||||||
"src/mobile/screens/admin/MAdminAddonManager.tsx": 2,
|
"src/mobile/screens/admin/MAdminAddonManager.tsx": 2,
|
||||||
"src/mobile/screens/admin/MAdminPluginsPanel.tsx": 6,
|
"src/mobile/screens/admin/MAdminPluginsPanel.tsx": 6,
|
||||||
"src/mobile/screens/journey/MJourneySettingsSheet.tsx": 1,
|
|
||||||
"src/mobile/screens/settings/MSettingsAccount.tsx": 1,
|
"src/mobile/screens/settings/MSettingsAccount.tsx": 1,
|
||||||
"src/mobile/screens/trip/MTripShell.tsx": 1,
|
"src/mobile/screens/trip/MTripShell.tsx": 1,
|
||||||
"src/mobile/screens/trip/map/MMapArea.tsx": 1,
|
"src/mobile/screens/trip/map/MMapArea.tsx": 1,
|
||||||
|
|||||||
@@ -79,12 +79,10 @@
|
|||||||
"components/Planner/BookingCostsSection.tsx": 1,
|
"components/Planner/BookingCostsSection.tsx": 1,
|
||||||
"components/Planner/BookingImportModal.tsx": 4,
|
"components/Planner/BookingImportModal.tsx": 4,
|
||||||
"components/Planner/DayDetailPanel.tsx": 1,
|
"components/Planner/DayDetailPanel.tsx": 1,
|
||||||
"components/Planner/IcsSubscribeModal.tsx": 10,
|
|
||||||
"components/Planner/PlaceInspector.tsx": 1,
|
"components/Planner/PlaceInspector.tsx": 1,
|
||||||
"components/Planner/PlacesSidebarMobileDayPicker.tsx": 3,
|
"components/Planner/PlacesSidebarMobileDayPicker.tsx": 3,
|
||||||
"components/Planner/SubscribeLinks.tsx": 5,
|
"components/Planner/SubscribeLinks.tsx": 5,
|
||||||
"components/Planner/SuggestionDropdown.tsx": 1,
|
"components/Planner/SuggestionDropdown.tsx": 1,
|
||||||
"components/Planner/TransitJourneyModal.tsx": 4,
|
|
||||||
"components/Planner/TransitSearchPanel.tsx": 2,
|
"components/Planner/TransitSearchPanel.tsx": 2,
|
||||||
"components/Planner/TravelerPicker.tsx": 3,
|
"components/Planner/TravelerPicker.tsx": 3,
|
||||||
"components/Planner/bookings/BookingsTimeline.tsx": 1,
|
"components/Planner/bookings/BookingsTimeline.tsx": 1,
|
||||||
@@ -134,7 +132,6 @@
|
|||||||
"components/shared/TrackColorPicker.tsx": 2,
|
"components/shared/TrackColorPicker.tsx": 2,
|
||||||
"components/shared/TripLoadingSplash.tsx": 10,
|
"components/shared/TripLoadingSplash.tsx": 10,
|
||||||
"mobile/components/MBadge.tsx": 2,
|
"mobile/components/MBadge.tsx": 2,
|
||||||
"mobile/components/MBottomNav.tsx": 2,
|
|
||||||
"mobile/components/MChip.tsx": 2,
|
"mobile/components/MChip.tsx": 2,
|
||||||
"mobile/components/MDayImpactList.tsx": 4,
|
"mobile/components/MDayImpactList.tsx": 4,
|
||||||
"mobile/components/MListRow.tsx": 1,
|
"mobile/components/MListRow.tsx": 1,
|
||||||
@@ -142,7 +139,6 @@
|
|||||||
"mobile/components/MSheet.tsx": 1,
|
"mobile/components/MSheet.tsx": 1,
|
||||||
"mobile/components/MStorageTestResult.tsx": 3,
|
"mobile/components/MStorageTestResult.tsx": 3,
|
||||||
"mobile/components/MToastHost.tsx": 2,
|
"mobile/components/MToastHost.tsx": 2,
|
||||||
"mobile/components/MUserPickerList.tsx": 1,
|
|
||||||
"mobile/screens/admin/MAdmin.tsx": 8,
|
"mobile/screens/admin/MAdmin.tsx": 8,
|
||||||
"mobile/screens/admin/MAdminAddonManager.tsx": 3,
|
"mobile/screens/admin/MAdminAddonManager.tsx": 3,
|
||||||
"mobile/screens/admin/MAdminAuditLogPanel.tsx": 15,
|
"mobile/screens/admin/MAdminAuditLogPanel.tsx": 15,
|
||||||
@@ -162,31 +158,18 @@
|
|||||||
"mobile/screens/admin/MAdminUi.tsx": 7,
|
"mobile/screens/admin/MAdminUi.tsx": 7,
|
||||||
"mobile/screens/admin/MAdminUsersSection.tsx": 13,
|
"mobile/screens/admin/MAdminUsersSection.tsx": 13,
|
||||||
"mobile/screens/admin/MApiProviderBlocks.tsx": 10,
|
"mobile/screens/admin/MApiProviderBlocks.tsx": 10,
|
||||||
"mobile/screens/atlas/MAtlasCountryPopup.tsx": 11,
|
|
||||||
"mobile/screens/atlas/MAtlasStatsCard.tsx": 2,
|
"mobile/screens/atlas/MAtlasStatsCard.tsx": 2,
|
||||||
"mobile/screens/collections/MCollAddSheet.tsx": 6,
|
|
||||||
"mobile/screens/collections/MCollCategoryPicker.tsx": 2,
|
|
||||||
"mobile/screens/collections/MCollEditSheet.tsx": 2,
|
|
||||||
"mobile/screens/collections/MCollLabelsSheet.tsx": 6,
|
|
||||||
"mobile/screens/collections/MCollLinksEditor.tsx": 2,
|
|
||||||
"mobile/screens/collections/MCollListPickerSheet.tsx": 3,
|
|
||||||
"mobile/screens/collections/MCollPlaceRow.tsx": 3,
|
"mobile/screens/collections/MCollPlaceRow.tsx": 3,
|
||||||
"mobile/screens/collections/MCollShareSheet.tsx": 14,
|
"mobile/screens/collections/MCollShareSheet.tsx": 1,
|
||||||
"mobile/screens/collections/MCollSheetKit.tsx": 5,
|
"mobile/screens/collections/MCollSheetKit.tsx": 3,
|
||||||
"mobile/screens/collections/MCollTripPickerSheet.tsx": 4,
|
"mobile/screens/collections/MCollections.tsx": 2,
|
||||||
"mobile/screens/collections/MCollections.tsx": 9,
|
"mobile/screens/dashboard/MDashboard.tsx": 25,
|
||||||
"mobile/screens/dashboard/MDashWidgets.tsx": 22,
|
"mobile/screens/dashboard/MNewTripSheet.tsx": 11,
|
||||||
"mobile/screens/dashboard/MDashboard.tsx": 30,
|
|
||||||
"mobile/screens/dashboard/MNewTripSheet.tsx": 12,
|
|
||||||
"mobile/screens/dashboard/MUserMenu.tsx": 7,
|
"mobile/screens/dashboard/MUserMenu.tsx": 7,
|
||||||
"mobile/screens/journey/MJourney.tsx": 10,
|
"mobile/screens/journey/MJourney.tsx": 10,
|
||||||
"mobile/screens/journey/MJourneyCreateSheet.tsx": 7,
|
"mobile/screens/journey/MJourneyDetail.tsx": 3,
|
||||||
"mobile/screens/journey/MJourneyDetail.tsx": 6,
|
"mobile/screens/journey/MJourneyEntrySheet.tsx": 11,
|
||||||
"mobile/screens/journey/MJourneyEntrySheet.tsx": 46,
|
|
||||||
"mobile/screens/journey/MJourneySettingsSheet.tsx": 2,
|
|
||||||
"mobile/screens/journey/mobileJourneyMeta.ts": 4,
|
"mobile/screens/journey/mobileJourneyMeta.ts": 4,
|
||||||
"mobile/screens/notifications/MNotificationRow.tsx": 4,
|
|
||||||
"mobile/screens/notifications/MNotifications.tsx": 3,
|
|
||||||
"mobile/screens/settings/MAirTrailConnectionSection.tsx": 2,
|
"mobile/screens/settings/MAirTrailConnectionSection.tsx": 2,
|
||||||
"mobile/screens/settings/MConfirmSheet.tsx": 2,
|
"mobile/screens/settings/MConfirmSheet.tsx": 2,
|
||||||
"mobile/screens/settings/MDawarichConnectionSection.tsx": 5,
|
"mobile/screens/settings/MDawarichConnectionSection.tsx": 5,
|
||||||
@@ -207,75 +190,49 @@
|
|||||||
"mobile/screens/settings/MSettingsUi.tsx": 10,
|
"mobile/screens/settings/MSettingsUi.tsx": 10,
|
||||||
"mobile/screens/settings/MWebPushCard.tsx": 1,
|
"mobile/screens/settings/MWebPushCard.tsx": 1,
|
||||||
"mobile/screens/trip/MTripLoadingSplash.tsx": 2,
|
"mobile/screens/trip/MTripLoadingSplash.tsx": 2,
|
||||||
"mobile/screens/trip/MTripShell.tsx": 7,
|
"mobile/screens/trip/MTripShell.tsx": 5,
|
||||||
"mobile/screens/trip/places/MPlacesBrowser.tsx": 10,
|
"mobile/screens/trip/places/MPlacesBrowser.tsx": 1,
|
||||||
"mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx": 2,
|
"mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx": 2,
|
||||||
"mobile/screens/trip/places/MPlacesFilterControls.tsx": 1,
|
"mobile/screens/trip/places/MPlacesFilterControls.tsx": 1,
|
||||||
"mobile/screens/trip/places/MPlacesSaveToCollectionSheet.tsx": 6,
|
"mobile/screens/trip/places/MPlacesSaveToCollectionSheet.tsx": 6,
|
||||||
"mobile/screens/trip/places/MPlacesToursModeSwitch.tsx": 1,
|
"mobile/screens/trip/plan/MPlanTimeline.tsx": 10,
|
||||||
"mobile/screens/trip/plan/MPlanTimeline.tsx": 12,
|
"mobile/screens/trip/plan/MPlanTimelineRows.tsx": 12,
|
||||||
"mobile/screens/trip/plan/MPlanTimelineRows.tsx": 24,
|
"mobile/screens/trip/roadtrip/MRoadtripRows.tsx": 18,
|
||||||
"mobile/screens/trip/roadtrip/MRoadtripRows.tsx": 31,
|
"mobile/screens/trip/roadtrip/MRoadtripTab.tsx": 11,
|
||||||
"mobile/screens/trip/roadtrip/MRoadtripTab.tsx": 16,
|
|
||||||
"mobile/screens/trip/roadtrip/MRtAlternativesBar.tsx": 8,
|
|
||||||
"mobile/screens/trip/roadtrip/MRtCorridorBar.tsx": 2,
|
"mobile/screens/trip/roadtrip/MRtCorridorBar.tsx": 2,
|
||||||
"mobile/screens/trip/roadtrip/MRtCorridorSheet.tsx": 7,
|
"mobile/screens/trip/roadtrip/MRtCorridorSheet.tsx": 4,
|
||||||
"mobile/screens/trip/roadtrip/MRtDraftSheet.tsx": 5,
|
"mobile/screens/trip/roadtrip/MRtKindSheet.tsx": 2,
|
||||||
"mobile/screens/trip/roadtrip/MRtInfoSheet.tsx": 9,
|
"mobile/screens/trip/roadtrip/MRtStopSheet.tsx": 3,
|
||||||
"mobile/screens/trip/roadtrip/MRtKindSheet.tsx": 3,
|
|
||||||
"mobile/screens/trip/roadtrip/MRtStaySheet.tsx": 17,
|
|
||||||
"mobile/screens/trip/roadtrip/MRtStopSheet.tsx": 12,
|
|
||||||
"mobile/screens/trip/sheets/ImpFileStep.tsx": 12,
|
|
||||||
"mobile/screens/trip/sheets/ImpListStep.tsx": 3,
|
|
||||||
"mobile/screens/trip/sheets/MAccommodationSheet.tsx": 10,
|
"mobile/screens/trip/sheets/MAccommodationSheet.tsx": 10,
|
||||||
"mobile/screens/trip/sheets/MBookingFields.tsx": 5,
|
"mobile/screens/trip/sheets/MBookingFields.tsx": 4,
|
||||||
"mobile/screens/trip/sheets/MBrowseActionsSheet.tsx": 3,
|
"mobile/screens/trip/sheets/MCostSheet.tsx": 23,
|
||||||
"mobile/screens/trip/sheets/MCostSheet.tsx": 33,
|
"mobile/screens/trip/sheets/MDaySheet.tsx": 5,
|
||||||
"mobile/screens/trip/sheets/MDaySheet.tsx": 22,
|
"mobile/screens/trip/sheets/MDaysSheet.tsx": 2,
|
||||||
"mobile/screens/trip/sheets/MDaysSheet.tsx": 4,
|
"mobile/screens/trip/sheets/MLinkedCosts.tsx": 7,
|
||||||
"mobile/screens/trip/sheets/MExportSheet.tsx": 2,
|
"mobile/screens/trip/sheets/MPlaceSheet.tsx": 6,
|
||||||
"mobile/screens/trip/sheets/MImportSheet.tsx": 2,
|
"mobile/screens/trip/sheets/MReservationSheet.tsx": 1,
|
||||||
"mobile/screens/trip/sheets/MLinkedCosts.tsx": 8,
|
"mobile/screens/trip/sheets/MTransportSheet.tsx": 6,
|
||||||
"mobile/screens/trip/sheets/MMehrSheet.tsx": 3,
|
|
||||||
"mobile/screens/trip/sheets/MNoteSheet.tsx": 1,
|
|
||||||
"mobile/screens/trip/sheets/MPlaceEditSheet.tsx": 2,
|
|
||||||
"mobile/screens/trip/sheets/MPlaceSheet.tsx": 23,
|
|
||||||
"mobile/screens/trip/sheets/MReservationSheet.tsx": 2,
|
|
||||||
"mobile/screens/trip/sheets/MTransportFormSheet.tsx": 9,
|
|
||||||
"mobile/screens/trip/sheets/MTransportSheet.tsx": 9,
|
|
||||||
"mobile/screens/trip/sheets/MTripSheetUi.tsx": 5,
|
"mobile/screens/trip/sheets/MTripSheetUi.tsx": 5,
|
||||||
"mobile/screens/trip/sheets/PlCategoryPicker.tsx": 1,
|
"mobile/screens/trip/sheets/PlCategoryPicker.tsx": 1,
|
||||||
"mobile/screens/trip/sheets/PlFileAttach.tsx": 3,
|
"mobile/screens/trip/sheets/PlPlaceSearch.tsx": 2,
|
||||||
"mobile/screens/trip/sheets/PlPlaceSearch.tsx": 6,
|
"mobile/screens/trip/sheets/PlSheetChrome.tsx": 1,
|
||||||
"mobile/screens/trip/sheets/PlSheetChrome.tsx": 5,
|
|
||||||
"mobile/screens/trip/sheets/PlTimeFields.tsx": 3,
|
"mobile/screens/trip/sheets/PlTimeFields.tsx": 3,
|
||||||
"mobile/screens/trip/tabs/MBagsSheet.tsx": 13,
|
"mobile/screens/trip/tabs/MBagsSheet.tsx": 13,
|
||||||
"mobile/screens/trip/tabs/MBookingsTab.tsx": 2,
|
"mobile/screens/trip/tabs/MCollabChat.tsx": 6,
|
||||||
"mobile/screens/trip/tabs/MCollabChat.tsx": 22,
|
"mobile/screens/trip/tabs/MCollabNotes.tsx": 4,
|
||||||
"mobile/screens/trip/tabs/MCollabNotes.tsx": 19,
|
"mobile/screens/trip/tabs/MCollabPolls.tsx": 12,
|
||||||
"mobile/screens/trip/tabs/MCollabPolls.tsx": 18,
|
|
||||||
"mobile/screens/trip/tabs/MCollabTab.tsx": 1,
|
"mobile/screens/trip/tabs/MCollabTab.tsx": 1,
|
||||||
"mobile/screens/trip/tabs/MCostsTab.tsx": 70,
|
"mobile/screens/trip/tabs/MCostsTab.tsx": 36,
|
||||||
"mobile/screens/trip/tabs/MDocSyncSheet.tsx": 43,
|
"mobile/screens/trip/tabs/MDocSyncSheet.tsx": 30,
|
||||||
"mobile/screens/trip/tabs/MFileLightbox.tsx": 11,
|
"mobile/screens/trip/tabs/MFileLightbox.tsx": 11,
|
||||||
"mobile/screens/trip/tabs/MFileLinkSheet.tsx": 2,
|
"mobile/screens/trip/tabs/MFilesTab.tsx": 2,
|
||||||
"mobile/screens/trip/tabs/MFileMenuSheet.tsx": 1,
|
|
||||||
"mobile/screens/trip/tabs/MFileTrashSheet.tsx": 4,
|
|
||||||
"mobile/screens/trip/tabs/MFilesTab.tsx": 12,
|
|
||||||
"mobile/screens/trip/tabs/MPackItemSheet.tsx": 1,
|
"mobile/screens/trip/tabs/MPackItemSheet.tsx": 1,
|
||||||
"mobile/screens/trip/tabs/MPackingImportSheet.tsx": 3,
|
|
||||||
"mobile/screens/trip/tabs/MPackingListTab.tsx": 2,
|
"mobile/screens/trip/tabs/MPackingListTab.tsx": 2,
|
||||||
"mobile/screens/trip/tabs/MReservationCardParts.tsx": 6,
|
"mobile/screens/trip/tabs/MTaskSheet.tsx": 1,
|
||||||
"mobile/screens/trip/tabs/MTaskSheet.tsx": 6,
|
"mobile/screens/trip/tabs/MTodoListTab.tsx": 2,
|
||||||
"mobile/screens/trip/tabs/MTodoListTab.tsx": 3,
|
|
||||||
"mobile/screens/trip/tabs/MTransportsTab.tsx": 2,
|
|
||||||
"mobile/screens/trip/tabs/filesModel.ts": 5,
|
"mobile/screens/trip/tabs/filesModel.ts": 5,
|
||||||
"mobile/screens/trip/tabs/tabChrome.tsx": 12,
|
"mobile/screens/trip/tabs/tabChrome.tsx": 3,
|
||||||
"mobile/screens/vacay/MVacay.tsx": 17,
|
"mobile/screens/vacay/MVacay.tsx": 1,
|
||||||
"mobile/screens/vacay/MVacayInviteSheet.tsx": 8,
|
|
||||||
"mobile/screens/vacay/MVacayMonth.tsx": 3,
|
|
||||||
"mobile/screens/vacay/MVacaySettingsSheet.tsx": 34,
|
|
||||||
"mobile/screens/vacay/MVacayShareSheet.tsx": 10,
|
|
||||||
"mobile/screens/vacay/vacayDayModel.ts": 1,
|
"mobile/screens/vacay/vacayDayModel.ts": 1,
|
||||||
"pages/DashboardPage.tsx": 1,
|
"pages/DashboardPage.tsx": 1,
|
||||||
"pages/FilesPage.tsx": 11,
|
"pages/FilesPage.tsx": 11,
|
||||||
|
|||||||
@@ -59,7 +59,6 @@
|
|||||||
"mobile/screens/atlas/MAtlasCountryPopup.tsx": 2,
|
"mobile/screens/atlas/MAtlasCountryPopup.tsx": 2,
|
||||||
"mobile/screens/atlas/hub/MHubTravellers.tsx": 1,
|
"mobile/screens/atlas/hub/MHubTravellers.tsx": 1,
|
||||||
"mobile/screens/collections/MCollEditSheet.tsx": 2,
|
"mobile/screens/collections/MCollEditSheet.tsx": 2,
|
||||||
"mobile/screens/collections/MCollShareSheet.tsx": 1,
|
|
||||||
"mobile/screens/collections/collectionsMobileModel.ts": 15,
|
"mobile/screens/collections/collectionsMobileModel.ts": 15,
|
||||||
"mobile/screens/dashboard/MDashboard.tsx": 3,
|
"mobile/screens/dashboard/MDashboard.tsx": 3,
|
||||||
"mobile/screens/journey/MJourney.tsx": 2,
|
"mobile/screens/journey/MJourney.tsx": 2,
|
||||||
|
|||||||
@@ -1,31 +1,22 @@
|
|||||||
|
import type { CollabLink } from '@trek/shared'
|
||||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||||
import { cloneElement, CSSProperties, FormEvent, ReactElement, useEffect, useId, useRef, useState } from 'react'
|
import { cloneElement, CSSProperties, FormEvent, ReactElement, useId, useState } from 'react'
|
||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import { ExternalLink, Link2, Pencil, Pin, Plus, Trash2, X } from 'lucide-react'
|
import { ExternalLink, Link2, Pencil, Pin, Plus, Trash2, X } from 'lucide-react'
|
||||||
import CollabPanelHead, { HEAD_ACTION } from './CollabPanelHead'
|
import CollabPanelHead, { HEAD_ACTION } from './CollabPanelHead'
|
||||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell'
|
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell'
|
||||||
import { EditorField, INPUT } from '../shared/dialogParts'
|
import { EditorField, INPUT } from '../shared/dialogParts'
|
||||||
import { useIsPhone } from '../../mobile/useIsPhone'
|
import { useIsPhone } from '../../mobile/useIsPhone'
|
||||||
import { collabApi } from '../../api/client'
|
|
||||||
import { addListener, removeListener } from '../../api/websocket'
|
|
||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
import { useCanDo } from '../../store/permissionsStore'
|
import { useCanDo } from '../../store/permissionsStore'
|
||||||
import { useTripStore } from '../../store/tripStore'
|
import { useTripStore } from '../../store/tripStore'
|
||||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||||
import EmptyState from '../shared/EmptyState'
|
import EmptyState from '../shared/EmptyState'
|
||||||
import { Tooltip } from '../shared/Tooltip'
|
import { Tooltip } from '../shared/Tooltip'
|
||||||
import { useToast } from '../shared/Toast'
|
import { collabLinkHost, useCollabLinks } from './useCollabLinks'
|
||||||
import { offlineOr } from '../../utils/needsConnection'
|
|
||||||
|
|
||||||
const FONT = "var(--font-system)"
|
const FONT = "var(--font-system)"
|
||||||
|
|
||||||
interface CollabLink {
|
|
||||||
id: number
|
|
||||||
title: string
|
|
||||||
url: string
|
|
||||||
pinned: boolean | number
|
|
||||||
}
|
|
||||||
|
|
||||||
// The glyph holds the place until a favicon has really arrived: a host that never
|
// The glyph holds the place until a favicon has really arrived: a host that never
|
||||||
// answers, or answers with a blank pixel, left the chip with an empty square.
|
// answers, or answers with a blank pixel, left the chip with an empty square.
|
||||||
function LinkIcon({ url }: { url: string }) {
|
function LinkIcon({ url }: { url: string }) {
|
||||||
@@ -56,10 +47,6 @@ function ChipTip({ label, phone, children }: { label: string; phone: boolean; ch
|
|||||||
return phone ? cloneElement(children, { title: label }) : <Tooltip label={label}>{children}</Tooltip>
|
return phone ? cloneElement(children, { title: label }) : <Tooltip label={label}>{children}</Tooltip>
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostOf(url: string): string {
|
|
||||||
try { return new URL(url).hostname.replace(/^www\./, '') } catch { return url }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The add and edit form as a modal, like the poll and note panels next to it.
|
* The add and edit form as a modal, like the poll and note panels next to it.
|
||||||
* Inline it pushed the list down and gave the panel a second header, which is
|
* Inline it pushed the list down and gave the panel a second header, which is
|
||||||
@@ -173,101 +160,11 @@ export default function CollabLinks({ tripId }: { tripId: number }) {
|
|||||||
const isPhone = useIsPhone()
|
const isPhone = useIsPhone()
|
||||||
const trip = useTripStore(s => s.trip)
|
const trip = useTripStore(s => s.trip)
|
||||||
const canEdit = useCanDo()('collab_edit', trip)
|
const canEdit = useCanDo()('collab_edit', trip)
|
||||||
const toast = useToast()
|
const { links, save, toggle, remove } = useCollabLinks(tripId)
|
||||||
const [links, setLinks] = useState<CollabLink[]>([])
|
|
||||||
const [showForm, setShowForm] = useState(false)
|
const [showForm, setShowForm] = useState(false)
|
||||||
const [editing, setEditing] = useState<CollabLink | null>(null)
|
const [editing, setEditing] = useState<CollabLink | null>(null)
|
||||||
const [pendingDeleteId, setPendingDeleteId] = useState<number | null>(null)
|
const [pendingDeleteId, setPendingDeleteId] = useState<number | null>(null)
|
||||||
|
|
||||||
// Both are new objects on every render, so depending on them would reload the
|
|
||||||
// list after each keystroke and drop a link that was just added back out of it.
|
|
||||||
const toastRef = useRef(toast)
|
|
||||||
toastRef.current = toast
|
|
||||||
const tRef = useRef(t)
|
|
||||||
tRef.current = t
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let cancelled = false
|
|
||||||
collabApi.getLinks(tripId)
|
|
||||||
.then(d => { if (!cancelled) setLinks(d.links || []) })
|
|
||||||
.catch(err => {
|
|
||||||
if (cancelled) return
|
|
||||||
console.error('Failed to load collab links:', err)
|
|
||||||
toastRef.current.error(tRef.current('common.error'))
|
|
||||||
})
|
|
||||||
return () => { cancelled = true }
|
|
||||||
}, [tripId])
|
|
||||||
|
|
||||||
// Live sync, the same shape the notes panel uses. Without it the three
|
|
||||||
// collab:link events the server broadcasts would arrive nowhere and a link
|
|
||||||
// somebody else added would only appear on the next reload.
|
|
||||||
useEffect(() => {
|
|
||||||
if (!tripId) return
|
|
||||||
const handler = (msg: { type?: string; tripId?: number | string; link?: CollabLink; linkId?: number }) => {
|
|
||||||
// The panel is not remounted on a trip change, so an event still in
|
|
||||||
// flight from the trip we just left must not land in this list.
|
|
||||||
if (String(msg?.tripId) !== String(tripId)) return
|
|
||||||
if (msg.type === 'collab:link:created' && msg.link) {
|
|
||||||
setLinks(prev => prev.some(l => l.id === msg.link!.id) ? prev : [msg.link!, ...prev])
|
|
||||||
}
|
|
||||||
if (msg.type === 'collab:link:updated' && msg.link) {
|
|
||||||
setLinks(prev => prev
|
|
||||||
.map(l => l.id === msg.link!.id ? { ...l, ...msg.link! } : l)
|
|
||||||
.sort((a, b) => Number(b.pinned) - Number(a.pinned)))
|
|
||||||
}
|
|
||||||
if (msg.type === 'collab:link:deleted' && msg.linkId) {
|
|
||||||
setLinks(prev => prev.filter(l => l.id !== msg.linkId))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addListener(handler)
|
|
||||||
return () => removeListener(handler)
|
|
||||||
}, [tripId])
|
|
||||||
|
|
||||||
// Every write says something when it fails. Silence left the pin looking
|
|
||||||
// unchanged and the delete looking ignored, with an unhandled rejection in
|
|
||||||
// the console as the only trace.
|
|
||||||
const add = async (data: { title: string; url: string }) => {
|
|
||||||
try {
|
|
||||||
const d = await collabApi.createLink(tripId, data)
|
|
||||||
setLinks(v => [d.link, ...v])
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to add collab link:', err)
|
|
||||||
toast.error(offlineOr(t, t('common.error')))
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggle = async (link: CollabLink) => {
|
|
||||||
try {
|
|
||||||
const d = await collabApi.updateLink(tripId, link.id, { pinned: !link.pinned })
|
|
||||||
setLinks(v => v.map(x => x.id === link.id ? d.link : x).sort((a, b) => Number(b.pinned) - Number(a.pinned)))
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to pin collab link:', err)
|
|
||||||
toast.error(offlineOr(t, t('common.error')))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const edit = async (link: CollabLink, data: { title: string; url: string }) => {
|
|
||||||
try {
|
|
||||||
const d = await collabApi.updateLink(tripId, link.id, data)
|
|
||||||
setLinks(v => v.map(x => x.id === link.id ? d.link : x))
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to edit collab link:', err)
|
|
||||||
toast.error(offlineOr(t, t('common.error')))
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const remove = async (id: number) => {
|
|
||||||
try {
|
|
||||||
await collabApi.deleteLink(tripId, id)
|
|
||||||
setLinks(v => v.filter(x => x.id !== id))
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to delete collab link:', err)
|
|
||||||
toast.error(offlineOr(t, t('common.error')))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', fontFamily: FONT }}>
|
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', fontFamily: FONT }}>
|
||||||
{/* Header: the desktop's head band; the phone keeps its own */}
|
{/* Header: the desktop's head band; the phone keeps its own */}
|
||||||
@@ -316,7 +213,7 @@ export default function CollabLinks({ tripId }: { tripId: number }) {
|
|||||||
<LinkIcon key={link.url} url={link.url} />
|
<LinkIcon key={link.url} url={link.url} />
|
||||||
<span className="collab-link-chip__text">
|
<span className="collab-link-chip__text">
|
||||||
<span className="collab-link-chip__title">{link.title}</span>
|
<span className="collab-link-chip__title">{link.title}</span>
|
||||||
<span className="collab-link-chip__host">{hostOf(link.url)}</span>
|
<span className="collab-link-chip__host">{collabLinkHost(link.url)}</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</ChipTip>
|
</ChipTip>
|
||||||
@@ -346,8 +243,8 @@ export default function CollabLinks({ tripId }: { tripId: number }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Create and edit modals */}
|
{/* Create and edit modals */}
|
||||||
{showForm && <LinkModal onClose={() => setShowForm(false)} onSave={add} />}
|
{showForm && <LinkModal onClose={() => setShowForm(false)} onSave={save} />}
|
||||||
{editing && <LinkModal key={editing.id} link={editing} onClose={() => setEditing(null)} onSave={data => edit(editing, data)} />}
|
{editing && <LinkModal key={editing.id} link={editing} onClose={() => setEditing(null)} onSave={data => save(data, editing.id)} />}
|
||||||
|
|
||||||
{/* The delete is shared: the link goes for every member, and on the phone the
|
{/* The delete is shared: the link goes for every member, and on the phone the
|
||||||
button is a thumb's width from pin. Same guard as the notes panel. */}
|
button is a thumb's width from pin. Same guard as the notes panel. */}
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ export function useCollabChatData({
|
|||||||
}: CollabChatDataOptions) {
|
}: CollabChatDataOptions) {
|
||||||
const [messages, setMessages] = useState<ChatMessage[]>([]);
|
const [messages, setMessages] = useState<ChatMessage[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [loadError, setLoadError] = useState(false);
|
||||||
|
const [loadAttempt, setLoadAttempt] = useState(0);
|
||||||
|
const retryLoad = useCallback(() => setLoadAttempt((attempt) => attempt + 1), []);
|
||||||
const [hasMore, setHasMore] = useState(false);
|
const [hasMore, setHasMore] = useState(false);
|
||||||
const [loadingMore, setLoadingMore] = useState(false);
|
const [loadingMore, setLoadingMore] = useState(false);
|
||||||
const [text, setText] = useState('');
|
const [text, setText] = useState('');
|
||||||
@@ -96,6 +99,7 @@ export function useCollabChatData({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
setLoadError(false);
|
||||||
collabApi
|
collabApi
|
||||||
.getMessages(tripId)
|
.getMessages(tripId)
|
||||||
.then((data: MessagesResponse) => {
|
.then((data: MessagesResponse) => {
|
||||||
@@ -107,12 +111,14 @@ export function useCollabChatData({
|
|||||||
setTimeout(() => scrollToBottom(), 30);
|
setTimeout(() => scrollToBottom(), 30);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
if (!cancelled) setLoading(false);
|
if (cancelled) return;
|
||||||
|
setLoadError(true);
|
||||||
|
setLoading(false);
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
};
|
};
|
||||||
}, [tripId, scrollToBottom]);
|
}, [tripId, loadAttempt, scrollToBottom]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handler = (event: Record<string, unknown>) => {
|
const handler = (event: Record<string, unknown>) => {
|
||||||
@@ -259,6 +265,8 @@ export function useCollabChatData({
|
|||||||
messages,
|
messages,
|
||||||
setMessages,
|
setMessages,
|
||||||
loading,
|
loading,
|
||||||
|
loadError,
|
||||||
|
retryLoad,
|
||||||
setLoading,
|
setLoading,
|
||||||
hasMore,
|
hasMore,
|
||||||
setHasMore,
|
setHasMore,
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
import type { CollabLink } from '@trek/shared';
|
||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { useTranslation } from '../../i18n';
|
||||||
|
import { collabLinkRepo, type LinkFields } from '../../repo/collabLinkRepo';
|
||||||
|
import { offlineOr } from '../../utils/needsConnection';
|
||||||
|
import { useToast } from '../shared/Toast';
|
||||||
|
|
||||||
|
type LinksState = { tripId: number; links: CollabLink[]; status: 'loading' | 'ready' | 'error' };
|
||||||
|
|
||||||
|
const EMPTY_LINKS: CollabLink[] = [];
|
||||||
|
|
||||||
|
export function collabLinkHost(url: string): string {
|
||||||
|
try {
|
||||||
|
return new URL(url).hostname.replace(/^www\./, '');
|
||||||
|
} catch {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertLink(links: CollabLink[], link: CollabLink): CollabLink[] {
|
||||||
|
return links.some((row) => row.id === link.id) ? links : [link, ...links];
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLink(links: CollabLink[], link: CollabLink): CollabLink[] {
|
||||||
|
return links
|
||||||
|
.map((row) => (row.id === link.id ? { ...row, ...link } : row))
|
||||||
|
.sort((a, b) => Number(b.pinned) - Number(a.pinned));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCollabLinks(tripId: number) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const toast = useToast();
|
||||||
|
const [state, setState] = useState<LinksState>({ tripId, links: EMPTY_LINKS, status: 'loading' });
|
||||||
|
const [attempt, setAttempt] = useState(0);
|
||||||
|
const reportLoadError = useRef(() => toast.error(t('common.error')));
|
||||||
|
reportLoadError.current = () => toast.error(t('common.error'));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
const changes: Array<(links: CollabLink[]) => CollabLink[]> = [];
|
||||||
|
let reading = true;
|
||||||
|
setState((current) => ({
|
||||||
|
tripId,
|
||||||
|
links: current.tripId === tripId ? current.links : EMPTY_LINKS,
|
||||||
|
status: 'loading',
|
||||||
|
}));
|
||||||
|
|
||||||
|
const handler = (msg: { type?: string; tripId?: number | string; link?: CollabLink; linkId?: number }) => {
|
||||||
|
if (String(msg.tripId) !== String(tripId)) return;
|
||||||
|
const { link, linkId } = msg;
|
||||||
|
const change =
|
||||||
|
msg.type === 'collab:link:created' && link
|
||||||
|
? (links: CollabLink[]) => insertLink(links, link)
|
||||||
|
: msg.type === 'collab:link:updated' && link
|
||||||
|
? (links: CollabLink[]) => updateLink(links, link)
|
||||||
|
: msg.type === 'collab:link:deleted' && linkId
|
||||||
|
? (links: CollabLink[]) => links.filter((row) => row.id !== linkId)
|
||||||
|
: null;
|
||||||
|
if (!change) return;
|
||||||
|
if (reading) changes.push(change);
|
||||||
|
setState((current) => (current.tripId === tripId ? { ...current, links: change(current.links) } : current));
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsubscribe = collabLinkRepo.subscribe(handler);
|
||||||
|
void collabLinkRepo.list(tripId).then(
|
||||||
|
(data) => {
|
||||||
|
if (cancelled) return;
|
||||||
|
reading = false;
|
||||||
|
const links = changes.reduce((rows, change) => change(rows), data.links || []);
|
||||||
|
setState({ tripId, links, status: 'ready' });
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
if (cancelled) return;
|
||||||
|
reading = false;
|
||||||
|
setState((current) => ({ ...current, status: 'error' }));
|
||||||
|
reportLoadError.current();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
unsubscribe();
|
||||||
|
};
|
||||||
|
}, [tripId, attempt]);
|
||||||
|
|
||||||
|
const changeLinks = (update: (links: CollabLink[]) => CollabLink[]) =>
|
||||||
|
setState((current) => (current.tripId === tripId ? { ...current, links: update(current.links) } : current));
|
||||||
|
const reportWriteError = () => toast.error(offlineOr(t, t('common.error')));
|
||||||
|
|
||||||
|
const save = async (data: LinkFields, id?: number) => {
|
||||||
|
try {
|
||||||
|
const { link } =
|
||||||
|
id == null ? await collabLinkRepo.create(tripId, data) : await collabLinkRepo.update(tripId, id, data);
|
||||||
|
changeLinks((links) => (id == null ? insertLink(links, link) : updateLink(links, link)));
|
||||||
|
} catch (error) {
|
||||||
|
reportWriteError();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggle = async (link: CollabLink) => {
|
||||||
|
try {
|
||||||
|
const { link: saved } = await collabLinkRepo.update(tripId, link.id, { pinned: !link.pinned });
|
||||||
|
changeLinks((links) => updateLink(links, saved));
|
||||||
|
} catch {
|
||||||
|
reportWriteError();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const remove = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await collabLinkRepo.remove(tripId, id);
|
||||||
|
changeLinks((links) => links.filter((link) => link.id !== id));
|
||||||
|
} catch {
|
||||||
|
reportWriteError();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
links: state.tripId === tripId ? state.links : EMPTY_LINKS,
|
||||||
|
status: state.tripId === tripId ? state.status : 'loading',
|
||||||
|
retry: () => setAttempt((value) => value + 1),
|
||||||
|
save,
|
||||||
|
toggle,
|
||||||
|
remove,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -122,7 +122,7 @@ describe('DuplicatePairCard', () => {
|
|||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
const { props, container } = setup({ variant: 'sheet' });
|
const { props, container } = setup({ variant: 'sheet' });
|
||||||
const card = within(container).getByRole('article');
|
const card = within(container).getByRole('article');
|
||||||
expect(card.className).toContain('bg-m-sheet');
|
expect(card).toHaveClass('bg-m-ic');
|
||||||
expect(screen.getByText('The same name at the same spot')).toBeInTheDocument();
|
expect(screen.getByText('The same name at the same spot')).toBeInTheDocument();
|
||||||
await user.click(screen.getAllByRole('button', { name: /Keep this one/ })[1]);
|
await user.click(screen.getAllByRole('button', { name: /Keep this one/ })[1]);
|
||||||
expect(props.onMerge).toHaveBeenCalledWith('b');
|
expect(props.onMerge).toHaveBeenCalledWith('b');
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const LOOK = {
|
|||||||
dialog: {
|
dialog: {
|
||||||
card: 'rounded-xl border border-edge-faint bg-surface-secondary p-3',
|
card: 'rounded-xl border border-edge-faint bg-surface-secondary p-3',
|
||||||
side: 'flex min-w-0 flex-col gap-1.5 rounded-lg bg-surface-card p-2.5',
|
side: 'flex min-w-0 flex-col gap-1.5 rounded-lg bg-surface-card p-2.5',
|
||||||
name: 'text-body font-semibold text-content',
|
name: 'truncate text-body font-semibold text-content',
|
||||||
sub: 'text-caption text-content-faint',
|
sub: 'text-caption text-content-faint',
|
||||||
diff: 'rounded bg-warning-soft px-1 text-content',
|
diff: 'rounded bg-warning-soft px-1 text-content',
|
||||||
chip: 'inline-flex max-w-full items-center gap-1 rounded-full border border-edge-faint px-2 py-0.5 text-caption text-content-muted',
|
chip: 'inline-flex max-w-full items-center gap-1 rounded-full border border-edge-faint px-2 py-0.5 text-caption text-content-muted',
|
||||||
@@ -18,16 +18,16 @@ const LOOK = {
|
|||||||
link: 'text-caption font-semibold text-content-muted hover:text-content disabled:opacity-50',
|
link: 'text-caption font-semibold text-content-muted hover:text-content disabled:opacity-50',
|
||||||
},
|
},
|
||||||
sheet: {
|
sheet: {
|
||||||
card: 'rounded-2xl border border-m-rowbr bg-m-sheet p-3',
|
card: 'rounded-[14px] bg-m-ic p-3',
|
||||||
side: 'flex min-w-0 flex-col gap-1.5 rounded-xl bg-m-sheetop p-2.5',
|
side: 'flex min-w-0 flex-col gap-2 rounded-xl border border-m-rowbr bg-m-sheetop p-2.5',
|
||||||
name: 'text-body font-bold text-m-ink',
|
name: 'line-clamp-2 break-words text-control font-semibold leading-tight text-m-ink',
|
||||||
sub: 'text-caption text-m-muted',
|
sub: 'text-caption text-m-muted',
|
||||||
diff: 'rounded bg-warning-soft px-1 text-m-ink',
|
diff: 'rounded bg-warning-soft px-1 text-m-ink',
|
||||||
chip: 'inline-flex max-w-full items-center gap-1 rounded-full border border-m-rowbr bg-m-ic px-2 py-0.5 text-caption text-m-muted',
|
chip: 'inline-flex max-w-full items-center gap-1 rounded-full border border-m-rowbr bg-m-ic px-2 py-0.5 text-caption text-m-muted',
|
||||||
keep: 'inline-flex items-center justify-center gap-1.5 rounded-full border border-m-rowbr bg-m-ic px-2.5 py-[7px] text-caption font-semibold text-m-ink disabled:opacity-50',
|
keep: 'inline-flex min-h-11 items-center justify-center gap-1.5 rounded-xl bg-m-ic px-2 py-2 text-start text-caption font-semibold leading-tight text-m-ink disabled:opacity-50',
|
||||||
reason: 'text-caption font-semibold text-m-muted',
|
reason: 'text-caption font-semibold text-m-muted',
|
||||||
note: 'text-caption text-m-faint',
|
note: 'text-caption text-m-faint',
|
||||||
link: 'text-caption font-semibold text-m-muted disabled:opacity-50',
|
link: 'min-h-11 rounded-xl px-2 text-start text-control font-medium text-m-muted active:bg-m-sheetop disabled:opacity-50',
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ function Side({
|
|||||||
differing.includes(field) ? <span className={look.diff}>{text}</span> : text;
|
differing.includes(field) ? <span className={look.diff}>{text}</span> : text;
|
||||||
return (
|
return (
|
||||||
<div className={look.side}>
|
<div className={look.side}>
|
||||||
<span dir="auto" className={`${look.name} truncate`}>
|
<span dir="auto" className={look.name}>
|
||||||
{mark('name', side.name)}
|
{mark('name', side.name)}
|
||||||
</span>
|
</span>
|
||||||
{(side.address || differing.includes('address')) && (
|
{(side.address || differing.includes('address')) && (
|
||||||
@@ -77,7 +77,11 @@ function Side({
|
|||||||
</span>
|
</span>
|
||||||
{canMerge && (
|
{canMerge && (
|
||||||
<button type="button" onClick={onKeep} disabled={busy} className={`mt-auto ${look.keep}`}>
|
<button type="button" onClick={onKeep} disabled={busy} className={`mt-auto ${look.keep}`}>
|
||||||
{busy ? <Loader2 size={12} className="animate-spin" /> : <Check size={12} />}{' '}
|
{busy ? (
|
||||||
|
<Loader2 size={12} className="flex-none animate-spin" aria-hidden />
|
||||||
|
) : (
|
||||||
|
<Check size={12} className="flex-none" aria-hidden />
|
||||||
|
)}
|
||||||
{t('collections.duplicates.keepThis')}
|
{t('collections.duplicates.keepThis')}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -85,6 +85,35 @@ describe('parseEntryKey and entryHasPosition', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('usePlacesLibrary: the first page', () => {
|
describe('usePlacesLibrary: the first page', () => {
|
||||||
|
it('uses the restored filters on its first request and opens the previous place', async () => {
|
||||||
|
const restoredDetail = libraryDetail(libraryEntry(), []);
|
||||||
|
list.mockResolvedValue(libraryPage([]));
|
||||||
|
detail.mockResolvedValue(restoredDetail);
|
||||||
|
const { result } = renderHook(() =>
|
||||||
|
usePlacesLibrary({
|
||||||
|
t,
|
||||||
|
active: true,
|
||||||
|
initialKey: 'trip:42',
|
||||||
|
initialFilters: {
|
||||||
|
search: 'Coffee',
|
||||||
|
kind: 'trip',
|
||||||
|
categoryId: 3,
|
||||||
|
sort: 'rating',
|
||||||
|
status: 'all',
|
||||||
|
minRating: 4,
|
||||||
|
tagNames: ['Morning'],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await waitFor(() => expect(result.current.detail).toBe(restoredDetail));
|
||||||
|
expect(list).toHaveBeenCalledWith(
|
||||||
|
{ q: 'Coffee', kind: 'trip', category_id: 3, sort: 'rating', min_rating: 4, tags: ['Morning'], limit: 60 },
|
||||||
|
expect.any(AbortSignal)
|
||||||
|
);
|
||||||
|
expect(detail).toHaveBeenCalledWith('trip', 42, expect.any(AbortSignal));
|
||||||
|
expect(result.current.search).toBe('Coffee');
|
||||||
|
});
|
||||||
|
|
||||||
it('FE-COMP-PLACESLIBHOOK-003: asks nothing while inactive and loads once it becomes active', async () => {
|
it('FE-COMP-PLACESLIBHOOK-003: asks nothing while inactive and loads once it becomes active', async () => {
|
||||||
list.mockResolvedValue(libraryPage([]));
|
list.mockResolvedValue(libraryPage([]));
|
||||||
const { rerender, result } = mount(false);
|
const { rerender, result } = mount(false);
|
||||||
|
|||||||
@@ -17,6 +17,16 @@ import { getApiErrorMessage } from '../../utils/apiError';
|
|||||||
/** Which origins the overview shows: all, only trip places, only saved ones. */
|
/** Which origins the overview shows: all, only trip places, only saved ones. */
|
||||||
export type LibraryKindFilter = 'all' | PlacesLibraryKind;
|
export type LibraryKindFilter = 'all' | PlacesLibraryKind;
|
||||||
|
|
||||||
|
export interface PlacesLibraryFilters {
|
||||||
|
search: string;
|
||||||
|
kind: LibraryKindFilter;
|
||||||
|
categoryId: number | 'all';
|
||||||
|
sort: PlacesLibrarySort;
|
||||||
|
status: CollectionStatus | 'all';
|
||||||
|
minRating: number | 'all';
|
||||||
|
tagNames: string[];
|
||||||
|
}
|
||||||
|
|
||||||
const PAGE = 60;
|
const PAGE = 60;
|
||||||
/** How long typing settles before the search asks the server. */
|
/** How long typing settles before the search asks the server. */
|
||||||
const SEARCH_SETTLE_MS = 250;
|
const SEARCH_SETTLE_MS = 250;
|
||||||
@@ -77,17 +87,17 @@ function failureOf(err: unknown, t: TranslationFn): { error: string | null; offl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The filters of "All places". */
|
/** The filters of "All places". */
|
||||||
function useLibraryFilters() {
|
function useLibraryFilters(initial?: PlacesLibraryFilters) {
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState(initial?.search ?? '');
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState(initial?.search.trim() ?? '');
|
||||||
const [kind, setKind] = useState<LibraryKindFilter>('all');
|
const [kind, setKind] = useState<LibraryKindFilter>(initial?.kind ?? 'all');
|
||||||
const [categoryId, setCategoryId] = useState<number | 'all'>('all');
|
const [categoryId, setCategoryId] = useState<number | 'all'>(initial?.categoryId ?? 'all');
|
||||||
const [sort, setSort] = useState<PlacesLibrarySort>('name');
|
const [sort, setSort] = useState<PlacesLibrarySort>(initial?.sort ?? 'name');
|
||||||
const [status, setStatus] = useState<CollectionStatus | 'all'>('all');
|
const [status, setStatus] = useState<CollectionStatus | 'all'>(initial?.status ?? 'all');
|
||||||
// At least this many stars on the average of the votes, as the lists filter; unrated places drop out.
|
// At least this many stars on the average of the votes, as the lists filter; unrated places drop out.
|
||||||
const [minRating, setMinRating] = useState<number | 'all'>('all');
|
const [minRating, setMinRating] = useState<number | 'all'>(initial?.minRating ?? 'all');
|
||||||
// PLC-21: tag names of the lists and trips, any of which an entry must carry, whatever their case.
|
// PLC-21: tag names of the lists and trips, any of which an entry must carry, whatever their case.
|
||||||
const [tagNames, setTagNames] = useState<string[]>([]);
|
const [tagNames, setTagNames] = useState<string[]>(initial?.tagNames ?? []);
|
||||||
const toggleTagName = useCallback(
|
const toggleTagName = useCallback(
|
||||||
(name: string) =>
|
(name: string) =>
|
||||||
setTagNames((names) => {
|
setTagNames((names) => {
|
||||||
@@ -158,8 +168,8 @@ function useLibraryFilters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The first page for the filters and the pages "more" appends. */
|
/** The first page for the filters and the pages "more" appends. */
|
||||||
function useLibraryPages(active: boolean, reloadSeq: number, t: TranslationFn) {
|
function useLibraryPages(active: boolean, reloadSeq: number, t: TranslationFn, initial?: PlacesLibraryFilters) {
|
||||||
const { filters, controls } = useLibraryFilters();
|
const { filters, controls } = useLibraryFilters(initial);
|
||||||
const [page, setPage] = useState<PageState>(EMPTY_PAGE);
|
const [page, setPage] = useState<PageState>(EMPTY_PAGE);
|
||||||
// The request "more" is loading for; another key means the button is free again.
|
// The request "more" is loading for; another key means the button is free again.
|
||||||
const [moreFor, setMoreFor] = useState<string | null>(null);
|
const [moreFor, setMoreFor] = useState<string | null>(null);
|
||||||
@@ -231,8 +241,13 @@ function useLibraryPages(active: boolean, reloadSeq: number, t: TranslationFn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The entry that is open and what its origins keep. */
|
/** The entry that is open and what its origins keep. */
|
||||||
function useLibraryDetail(entries: readonly PlacesLibraryEntry[], reloadSeq: number, onError: (err: unknown) => void) {
|
function useLibraryDetail(
|
||||||
const [selectedKey, setSelectedKey] = useState<string | null>(null);
|
entries: readonly PlacesLibraryEntry[],
|
||||||
|
reloadSeq: number,
|
||||||
|
onError: (err: unknown) => void,
|
||||||
|
initialKey?: string
|
||||||
|
) {
|
||||||
|
const [selectedKey, setSelectedKey] = useState<string | null>(initialKey ?? null);
|
||||||
const [loaded, setLoaded] = useState<{ key: string; detail: PlacesLibraryDetailResponse } | null>(null);
|
const [loaded, setLoaded] = useState<{ key: string; detail: PlacesLibraryDetailResponse } | null>(null);
|
||||||
const [settled, setSettled] = useState<string | null>(null);
|
const [settled, setSettled] = useState<string | null>(null);
|
||||||
// Where the open entry is read from, as text so a page arriving later does not ask again.
|
// Where the open entry is read from, as text so a page arriving later does not ask again.
|
||||||
@@ -348,15 +363,25 @@ export function useTagOptions(entries: readonly PlacesLibraryEntry[], picked: re
|
|||||||
* fresh first page, "more" appends the next one, and opening an entry loads what
|
* fresh first page, "more" appends the next one, and opening an entry loads what
|
||||||
* each of its origins keeps.
|
* each of its origins keeps.
|
||||||
*/
|
*/
|
||||||
export function usePlacesLibrary({ active, t }: { active: boolean; t: TranslationFn }) {
|
export function usePlacesLibrary({
|
||||||
|
active,
|
||||||
|
t,
|
||||||
|
initialFilters,
|
||||||
|
initialKey,
|
||||||
|
}: {
|
||||||
|
active: boolean;
|
||||||
|
t: TranslationFn;
|
||||||
|
initialFilters?: PlacesLibraryFilters;
|
||||||
|
initialKey?: string;
|
||||||
|
}) {
|
||||||
const [ownSeq, setReloadSeq] = useState(0);
|
const [ownSeq, setReloadSeq] = useState(0);
|
||||||
// A place saved to a list from here or anywhere else adds an origin: read again then too.
|
// A place saved to a list from here or anywhere else adds an origin: read again then too.
|
||||||
const savedVersion = useSaveToCollectionStore((st) => st.version);
|
const savedVersion = useSaveToCollectionStore((st) => st.version);
|
||||||
const reloadSeq = ownSeq + savedVersion;
|
const reloadSeq = ownSeq + savedVersion;
|
||||||
const [detailError, setDetailError] = useState<{ error: string | null; offline: boolean } | null>(null);
|
const [detailError, setDetailError] = useState<{ error: string | null; offline: boolean } | null>(null);
|
||||||
const pages = useLibraryPages(active, reloadSeq, t);
|
const pages = useLibraryPages(active, reloadSeq, t, initialFilters);
|
||||||
const onDetailError = useCallback((err: unknown) => setDetailError(failureOf(err, t)), [t]);
|
const onDetailError = useCallback((err: unknown) => setDetailError(failureOf(err, t)), [t]);
|
||||||
const sel = useLibraryDetail(pages.page.entries, reloadSeq, onDetailError);
|
const sel = useLibraryDetail(pages.page.entries, reloadSeq, onDetailError, initialKey);
|
||||||
const cover = useLibraryCover(sel.detail);
|
const cover = useLibraryCover(sel.detail);
|
||||||
const reload = useCallback(() => {
|
const reload = useCallback(() => {
|
||||||
setDetailError(null);
|
setDetailError(null);
|
||||||
|
|||||||
@@ -440,9 +440,9 @@ describe('DawarichAcceptDialog', () => {
|
|||||||
phone.value = true
|
phone.value = true
|
||||||
const { onConfirm } = open({ trips: TRIPS, daysForTrip })
|
const { onConfirm } = open({ trips: TRIPS, daysForTrip })
|
||||||
|
|
||||||
expect(screen.getByRole('dialog', { name: 'Add this stay as a place' })).toBeInTheDocument()
|
const sheet = screen.getByRole('dialog', { name: 'Add this stay as a place' })
|
||||||
// The desktop modal's own heading is the tell that the wrong shell rendered.
|
expect(sheet).toHaveAttribute('data-m-sheet', 'open')
|
||||||
expect(screen.queryByRole('heading', { name: 'Add this stay as a place' })).toBeNull()
|
expect(screen.getByRole('heading', { name: 'Add this stay as a place' })).toBeInTheDocument()
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'Reichard' } })
|
fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'Reichard' } })
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Add place' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Add place' }))
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event'
|
|||||||
import { render, screen, waitFor, act } from '../../../tests/helpers/render'
|
import { render, screen, waitFor, act } from '../../../tests/helpers/render'
|
||||||
import { server } from '../../../tests/helpers/msw/server'
|
import { server } from '../../../tests/helpers/msw/server'
|
||||||
import ContributorInviteDialog from './ContributorInviteDialog'
|
import ContributorInviteDialog from './ContributorInviteDialog'
|
||||||
|
import MJourneyInviteFrame from '../../mobile/screens/journey/MJourneyInviteFrame'
|
||||||
|
|
||||||
type ToastKind = 'success' | 'error' | 'warning' | 'info'
|
type ToastKind = 'success' | 'error' | 'warning' | 'info'
|
||||||
|
|
||||||
@@ -198,29 +199,22 @@ describe('ContributorInviteDialog on a phone', () => {
|
|||||||
Object.defineProperty(window, 'innerWidth', { value: width, configurable: true, writable: true })
|
Object.defineProperty(window, 'innerWidth', { value: width, configurable: true, writable: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('FE-JRN-INVITE-013: keeps the panel it had, with the filled role button and the header close', async () => {
|
it('FE-JRN-INVITE-013: uses the mobile sheet with a labelled role selector and close action', async () => {
|
||||||
const user = userEvent.setup()
|
const user = userEvent.setup()
|
||||||
const { onClose, onInvited } = mountDialog()
|
const { onClose, onInvited } = mountDialog({ Frame: MJourneyInviteFrame })
|
||||||
await screen.findByText('maurice')
|
await screen.findByText('maurice')
|
||||||
|
|
||||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
expect(screen.getByRole('dialog', { name: 'Invite Contributor' })).toBeInTheDocument()
|
||||||
const viewerBtn = screen.getByRole('button', { name: 'Viewer' })
|
const viewerBtn = screen.getByRole('button', { name: 'Viewer' })
|
||||||
const editorBtn = screen.getByRole('button', { name: 'Editor' })
|
const editorBtn = screen.getByRole('button', { name: 'Editor' })
|
||||||
expect(viewerBtn.className).toContain('bg-zinc-900')
|
expect(viewerBtn).toHaveAttribute('aria-pressed', 'true')
|
||||||
expect(editorBtn.className).not.toContain('bg-zinc-900')
|
expect(editorBtn).toHaveAttribute('aria-pressed', 'false')
|
||||||
|
|
||||||
await user.click(editorBtn)
|
await user.click(editorBtn)
|
||||||
expect(editorBtn.className).toContain('bg-zinc-900')
|
expect(editorBtn).toHaveAttribute('aria-pressed', 'true')
|
||||||
expect(viewerBtn.className).not.toContain('bg-zinc-900')
|
expect(viewerBtn).toHaveAttribute('aria-pressed', 'false')
|
||||||
|
|
||||||
// The header close button carries only an icon, so it is addressed by position.
|
await user.click(screen.getByRole('button', { name: 'Close' }))
|
||||||
const headerClose = screen.getByRole('heading', { name: 'Invite Contributor' })
|
|
||||||
.parentElement!.querySelector('button')!
|
|
||||||
act(() => { headerClose.click() })
|
|
||||||
expect(onClose).toHaveBeenCalledTimes(1)
|
|
||||||
|
|
||||||
// Escape is the desktop's: the phone panel never had it.
|
|
||||||
await user.keyboard('{Escape}')
|
|
||||||
expect(onClose).toHaveBeenCalledTimes(1)
|
expect(onClose).toHaveBeenCalledTimes(1)
|
||||||
expect(onInvited).not.toHaveBeenCalled()
|
expect(onInvited).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@@ -232,7 +226,7 @@ describe('ContributorInviteDialog on a phone', () => {
|
|||||||
return HttpResponse.json({ ok: true })
|
return HttpResponse.json({ ok: true })
|
||||||
}))
|
}))
|
||||||
const user = userEvent.setup()
|
const user = userEvent.setup()
|
||||||
const { onInvited } = mountDialog({ existingUserIds: [1] })
|
const { onInvited } = mountDialog({ existingUserIds: [1], Frame: MJourneyInviteFrame })
|
||||||
await screen.findByText('julien')
|
await screen.findByText('julien')
|
||||||
|
|
||||||
await user.type(screen.getByPlaceholderText('Username or email...'), 'zzz')
|
await user.type(screen.getByPlaceholderText('Username or email...'), 'zzz')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useId, useState } from 'react'
|
import { useEffect, useId, useState, type ComponentType } from 'react'
|
||||||
import { X, Check, UserPlus, Search, Loader2 } from 'lucide-react'
|
import { X, Check, UserPlus, Search, Loader2 } from 'lucide-react'
|
||||||
import { journeyApi, authApi } from '../../api/client'
|
import { journeyApi, authApi } from '../../api/client'
|
||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
@@ -10,37 +10,56 @@ import { TripMemberAvatar } from '../Trips/TripMemberAvatar'
|
|||||||
import { avatarSrc } from '../../utils/avatarSrc'
|
import { avatarSrc } from '../../utils/avatarSrc'
|
||||||
|
|
||||||
const ROLES = ['viewer', 'editor'] as const
|
const ROLES = ['viewer', 'editor'] as const
|
||||||
|
type InviteRole = (typeof ROLES)[number]
|
||||||
|
type InviteUser = { id: number; username: string; email?: string; avatar?: string | null }
|
||||||
|
|
||||||
|
export interface ContributorInviteFrameProps {
|
||||||
|
users: InviteUser[]
|
||||||
|
loading: boolean
|
||||||
|
search: string
|
||||||
|
onSearch: (value: string) => void
|
||||||
|
selectedUserId: number | null
|
||||||
|
onSelectUser: (id: number) => void
|
||||||
|
role: InviteRole
|
||||||
|
roles: readonly InviteRole[]
|
||||||
|
onRoleChange: (role: InviteRole) => void
|
||||||
|
sending: boolean
|
||||||
|
onClose: () => void
|
||||||
|
onInvite: () => Promise<void>
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a person to a journey. The desktop draws it in the planner's dialog
|
* Adds a person to a journey. The desktop draws it in the planner's dialog
|
||||||
* frame; the phone, which opens it from its journey screen, keeps the panel it
|
* frame; the phone, which opens it from its journey screen, keeps the panel it
|
||||||
* has always had. Both read and write the same state below.
|
* has always had. Both read and write the same state below.
|
||||||
*/
|
*/
|
||||||
export default function ContributorInviteDialog({ journeyId, existingUserIds, onClose, onInvited }: {
|
export default function ContributorInviteDialog({ journeyId, existingUserIds, onClose, onInvited, Frame }: {
|
||||||
journeyId: number
|
journeyId: number
|
||||||
existingUserIds: number[]
|
existingUserIds: number[]
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
onInvited: () => void
|
onInvited: () => void
|
||||||
|
Frame?: ComponentType<ContributorInviteFrameProps>
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const phone = useIsPhone()
|
const phone = useIsPhone()
|
||||||
const labelId = useId()
|
const labelId = useId()
|
||||||
const [users, setUsers] = useState<{ id: number; username: string; email?: string; avatar?: string | null }[]>([])
|
const [users, setUsers] = useState<InviteUser[]>([])
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
const [selectedUserId, setSelectedUserId] = useState<number | null>(null)
|
const [selectedUserId, setSelectedUserId] = useState<number | null>(null)
|
||||||
const [role, setRole] = useState<'editor' | 'viewer'>('viewer')
|
const [role, setRole] = useState<InviteRole>('viewer')
|
||||||
const [sending, setSending] = useState(false)
|
const [sending, setSending] = useState(false)
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
authApi.listUsers().then(d => setUsers(d.users || [])).catch(() => {})
|
authApi.listUsers().then(d => setUsers(d.users || [])).catch(() => setUsers([])).finally(() => setLoading(false))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Captured and stopped on the desktop: the dialog is usually opened from the
|
// Captured and stopped on the desktop: the dialog is usually opened from the
|
||||||
// journey settings, which close on Escape as well, and one key press should
|
// journey settings, which close on Escape as well, and one key press should
|
||||||
// only take back this dialog, not the one under it.
|
// only take back this dialog, not the one under it.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (phone) return
|
if (phone || Frame) return
|
||||||
const onKey = (e: KeyboardEvent) => {
|
const onKey = (e: KeyboardEvent) => {
|
||||||
if (e.key !== 'Escape') return
|
if (e.key !== 'Escape') return
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@@ -48,7 +67,7 @@ export default function ContributorInviteDialog({ journeyId, existingUserIds, on
|
|||||||
}
|
}
|
||||||
document.addEventListener('keydown', onKey, true)
|
document.addEventListener('keydown', onKey, true)
|
||||||
return () => document.removeEventListener('keydown', onKey, true)
|
return () => document.removeEventListener('keydown', onKey, true)
|
||||||
}, [phone, onClose])
|
}, [phone, Frame, onClose])
|
||||||
|
|
||||||
const filtered = users.filter(u => {
|
const filtered = users.filter(u => {
|
||||||
if (existingUserIds.includes(u.id)) return false
|
if (existingUserIds.includes(u.id)) return false
|
||||||
@@ -59,7 +78,7 @@ export default function ContributorInviteDialog({ journeyId, existingUserIds, on
|
|||||||
})
|
})
|
||||||
|
|
||||||
const handleInvite = async () => {
|
const handleInvite = async () => {
|
||||||
if (!selectedUserId) return
|
if (!selectedUserId || sending) return
|
||||||
setSending(true)
|
setSending(true)
|
||||||
try {
|
try {
|
||||||
await journeyApi.addContributor(journeyId, selectedUserId, role)
|
await journeyApi.addContributor(journeyId, selectedUserId, role)
|
||||||
@@ -72,6 +91,12 @@ export default function ContributorInviteDialog({ journeyId, existingUserIds, on
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Frame) {
|
||||||
|
return <Frame users={filtered} loading={loading} search={search} onSearch={setSearch}
|
||||||
|
selectedUserId={selectedUserId} onSelectUser={setSelectedUserId} role={role} roles={ROLES}
|
||||||
|
onRoleChange={setRole} sending={sending} onClose={onClose} onInvite={handleInvite} />
|
||||||
|
}
|
||||||
|
|
||||||
if (phone) {
|
if (phone) {
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 z-[200] flex items-center justify-center p-5 bg-[rgba(9,9,11,0.75)]">
|
<div className="fixed inset-0 z-[200] flex items-center justify-center p-5 bg-[rgba(9,9,11,0.75)]">
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ interface Props {
|
|||||||
publicHint?: boolean;
|
publicHint?: boolean;
|
||||||
/** Start unfolded, where the thread already has a section of its own. */
|
/** Start unfolded, where the thread already has a section of its own. */
|
||||||
defaultOpen?: boolean;
|
defaultOpen?: boolean;
|
||||||
|
mobile?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GUEST_NAME_KEY = 'trek.journey.guestName';
|
const GUEST_NAME_KEY = 'trek.journey.guestName';
|
||||||
@@ -68,9 +69,10 @@ export default function JourneyEntryComments({
|
|||||||
onDelete,
|
onDelete,
|
||||||
publicHint,
|
publicHint,
|
||||||
defaultOpen,
|
defaultOpen,
|
||||||
|
mobile = false,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { t, locale } = useTranslation();
|
const { t, locale } = useTranslation();
|
||||||
const [open, setOpen] = useState(!!defaultOpen);
|
const [expanded, setExpanded] = useState<boolean | null>(null);
|
||||||
const [body, setBody] = useState('');
|
const [body, setBody] = useState('');
|
||||||
const [name, setName] = useState(guest ? rememberedName : '');
|
const [name, setName] = useState(guest ? rememberedName : '');
|
||||||
const [trap, setTrap] = useState('');
|
const [trap, setTrap] = useState('');
|
||||||
@@ -78,6 +80,7 @@ export default function JourneyEntryComments({
|
|||||||
const [message, setMessage] = useState<string | null>(null);
|
const [message, setMessage] = useState<string | null>(null);
|
||||||
|
|
||||||
if (!canWrite && comments.length === 0) return null;
|
if (!canWrite && comments.length === 0) return null;
|
||||||
|
const open = expanded ?? Boolean(defaultOpen || (mobile && comments.length));
|
||||||
|
|
||||||
const submit = async (e: FormEvent) => {
|
const submit = async (e: FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -108,9 +111,13 @@ export default function JourneyEntryComments({
|
|||||||
aria-expanded={open}
|
aria-expanded={open}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setOpen((shown) => !shown);
|
setExpanded(!open);
|
||||||
}}
|
}}
|
||||||
className="inline-flex items-center gap-1.5 self-start text-caption font-medium text-content-faint transition-colors hover:text-content"
|
className={
|
||||||
|
mobile
|
||||||
|
? 'flex min-h-11 w-full items-center gap-2 rounded-xl bg-m-sheetop px-3 text-start text-control font-medium text-m-ink'
|
||||||
|
: 'inline-flex items-center gap-1.5 self-start text-caption font-medium text-content-faint transition-colors hover:text-content'
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<MessageCircle size={13} />
|
<MessageCircle size={13} />
|
||||||
{comments.length > 0 ? t('journey.comments.count', { count: comments.length }) : t('journey.comments.write')}
|
{comments.length > 0 ? t('journey.comments.count', { count: comments.length }) : t('journey.comments.write')}
|
||||||
@@ -121,7 +128,7 @@ export default function JourneyEntryComments({
|
|||||||
return (
|
return (
|
||||||
// The thread sits inside clickable cards: a click in it must not open the entry.
|
// The thread sits inside clickable cards: a click in it must not open the entry.
|
||||||
<div className="flex flex-col gap-3" onClick={(e) => e.stopPropagation()} role="presentation">
|
<div className="flex flex-col gap-3" onClick={(e) => e.stopPropagation()} role="presentation">
|
||||||
{!defaultOpen && toggle}
|
{!defaultOpen && !mobile && toggle}
|
||||||
{comments.length > 0 && (
|
{comments.length > 0 && (
|
||||||
<ul className="flex flex-col gap-2.5">
|
<ul className="flex flex-col gap-2.5">
|
||||||
{comments.map((c) => {
|
{comments.map((c) => {
|
||||||
@@ -149,7 +156,13 @@ export default function JourneyEntryComments({
|
|||||||
<p className="mt-0.5 whitespace-pre-wrap break-words text-body text-content-muted">{c.body}</p>
|
<p className="mt-0.5 whitespace-pre-wrap break-words text-body text-content-muted">{c.body}</p>
|
||||||
</div>
|
</div>
|
||||||
{(mayHide || mayDelete) && (
|
{(mayHide || mayDelete) && (
|
||||||
<div className="flex flex-none items-center gap-0.5 opacity-40 transition-opacity group-hover:opacity-100">
|
<div
|
||||||
|
className={
|
||||||
|
mobile
|
||||||
|
? 'flex flex-none items-center gap-0.5'
|
||||||
|
: 'flex flex-none items-center gap-0.5 opacity-40 transition-opacity group-hover:opacity-100'
|
||||||
|
}
|
||||||
|
>
|
||||||
{mayHide && (
|
{mayHide && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={c.hidden ? t('journey.comments.show') : t('journey.comments.hide')}
|
label={c.hidden ? t('journey.comments.show') : t('journey.comments.hide')}
|
||||||
@@ -159,7 +172,7 @@ export default function JourneyEntryComments({
|
|||||||
type="button"
|
type="button"
|
||||||
aria-label={c.hidden ? t('journey.comments.show') : t('journey.comments.hide')}
|
aria-label={c.hidden ? t('journey.comments.show') : t('journey.comments.hide')}
|
||||||
onClick={() => void onHide?.(c.id, !c.hidden)}
|
onClick={() => void onHide?.(c.id, !c.hidden)}
|
||||||
className="flex h-7 w-7 items-center justify-center rounded-full text-content-faint hover:bg-surface-secondary hover:text-content"
|
className={`flex ${mobile ? 'size-11' : 'size-7'} items-center justify-center rounded-full text-content-faint hover:bg-surface-secondary hover:text-content`}
|
||||||
>
|
>
|
||||||
{c.hidden ? <Eye size={13} /> : <EyeOff size={13} />}
|
{c.hidden ? <Eye size={13} /> : <EyeOff size={13} />}
|
||||||
</button>
|
</button>
|
||||||
@@ -171,7 +184,7 @@ export default function JourneyEntryComments({
|
|||||||
type="button"
|
type="button"
|
||||||
aria-label={t('common.delete')}
|
aria-label={t('common.delete')}
|
||||||
onClick={() => void onDelete?.(c.id)}
|
onClick={() => void onDelete?.(c.id)}
|
||||||
className="flex h-7 w-7 items-center justify-center rounded-full text-content-faint hover:bg-danger-soft hover:text-danger"
|
className={`flex ${mobile ? 'size-11' : 'size-7'} items-center justify-center rounded-full text-content-faint hover:bg-danger-soft hover:text-danger`}
|
||||||
>
|
>
|
||||||
<Trash2 size={13} />
|
<Trash2 size={13} />
|
||||||
</button>
|
</button>
|
||||||
@@ -216,14 +229,22 @@ export default function JourneyEntryComments({
|
|||||||
rows={1}
|
rows={1}
|
||||||
placeholder={t('journey.comments.write')}
|
placeholder={t('journey.comments.write')}
|
||||||
aria-label={t('journey.comments.write')}
|
aria-label={t('journey.comments.write')}
|
||||||
className="max-h-40 min-h-[38px] flex-1 resize-none rounded-xl border border-edge bg-surface px-3 py-2 text-body text-content outline-none [field-sizing:content] placeholder:text-content-faint focus:border-content-faint"
|
className={`max-h-40 min-w-0 flex-1 resize-none rounded-xl border px-3 py-2 text-body outline-none [field-sizing:content] ${
|
||||||
|
mobile
|
||||||
|
? 'min-h-11 border-m-rowbr bg-m-sheetop text-m-ink placeholder:text-m-muted'
|
||||||
|
: 'min-h-[38px] border-edge bg-surface text-content placeholder:text-content-faint focus:border-content-faint'
|
||||||
|
}`}
|
||||||
/>
|
/>
|
||||||
<Tooltip label={t('journey.comments.send')} placement="top">
|
<Tooltip label={t('journey.comments.send')} placement="top">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
aria-label={t('journey.comments.send')}
|
aria-label={t('journey.comments.send')}
|
||||||
disabled={busy || !body.trim() || (guest && !name.trim())}
|
disabled={busy || !body.trim() || (guest && !name.trim())}
|
||||||
className="flex h-[38px] w-[38px] flex-none items-center justify-center rounded-full bg-accent text-accent-text transition-opacity hover:bg-accent-hover disabled:opacity-40"
|
className={`flex flex-none items-center justify-center rounded-full transition-opacity disabled:opacity-40 ${
|
||||||
|
mobile
|
||||||
|
? 'size-11 bg-m-act text-m-actfg'
|
||||||
|
: 'size-[38px] bg-accent text-accent-text hover:bg-accent-hover'
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<SendHorizontal size={15} />
|
<SendHorizontal size={15} />
|
||||||
</button>
|
</button>
|
||||||
@@ -231,7 +252,9 @@ export default function JourneyEntryComments({
|
|||||||
</div>
|
</div>
|
||||||
{message && <p className="text-caption text-danger">{message}</p>}
|
{message && <p className="text-caption text-danger">{message}</p>}
|
||||||
{publicHint && !guest && (
|
{publicHint && !guest && (
|
||||||
<p className="text-caption text-content-faint">{t('journey.comments.publicHint')}</p>
|
<p className={`text-caption ${mobile ? 'font-normal text-m-muted' : 'text-content-faint'}`}>
|
||||||
|
{t('journey.comments.publicHint')}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
)}
|
)}
|
||||||
@@ -252,10 +275,12 @@ export function MemberEntryComments({
|
|||||||
entryId,
|
entryId,
|
||||||
thread,
|
thread,
|
||||||
defaultOpen,
|
defaultOpen,
|
||||||
|
mobile,
|
||||||
}: {
|
}: {
|
||||||
entryId: number;
|
entryId: number;
|
||||||
thread: MemberThreadState;
|
thread: MemberThreadState;
|
||||||
defaultOpen?: boolean;
|
defaultOpen?: boolean;
|
||||||
|
mobile?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
@@ -268,6 +293,7 @@ export function MemberEntryComments({
|
|||||||
comments={thread.byEntry.get(entryId) ?? []}
|
comments={thread.byEntry.get(entryId) ?? []}
|
||||||
canWrite
|
canWrite
|
||||||
defaultOpen={defaultOpen}
|
defaultOpen={defaultOpen}
|
||||||
|
mobile={mobile}
|
||||||
canModerate={thread.canModerate}
|
canModerate={thread.canModerate}
|
||||||
publicHint
|
publicHint
|
||||||
onAdd={async (body) => ((await thread.add(entryId, body)) ? null : t('journey.comments.failed'))}
|
onAdd={async (body) => ((await thread.add(entryId, body)) ? null : t('journey.comments.failed'))}
|
||||||
|
|||||||
@@ -134,14 +134,13 @@ describe('JourneyEntryCover', () => {
|
|||||||
expect(container.querySelector('svg.lucide-play')).toBeNull()
|
expect(container.querySelector('svg.lucide-play')).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('FE-JRN-COVER-011: only the phone draws a card without a photo in the deep day colour, opaque even as a suggestion', () => {
|
it('FE-JRN-COVER-011: the phone shows a neutral surface for suggestions without photos', () => {
|
||||||
const entry = buildEntry({ photos: [], type: 'skeleton' })
|
const entry = buildEntry({ photos: [], type: 'skeleton' })
|
||||||
const phone = render(<JourneyEntryCover entry={entry} dayColor="#6366f1" isActive={false} onClick={() => {}} tone="mobile" />)
|
const phone = render(<JourneyEntryCover entry={entry} dayColor="#6366f1" isActive={false} onClick={() => {}} tone="mobile" />)
|
||||||
const phoneCard = phone.getByRole('button')
|
const phoneCard = phone.getByRole('button')
|
||||||
// d9, the deep wash (jsdom spells the colour out as rgba)
|
expect(phoneCard.style.backgroundImage).toBe('')
|
||||||
expect(phoneCard.style.backgroundImage).toMatch(/rgba\(99, 102, 241, 0\.85/)
|
expect(phoneCard).toHaveClass('bg-m-sheetop', 'text-m-ink')
|
||||||
expect(phoneCard.className).not.toContain('opacity-90')
|
expect(phone.container.querySelector('svg.lucide-map-pin')).not.toBeInTheDocument()
|
||||||
expect(phone.container.querySelector('svg.lucide-map-pin')?.getAttribute('class')).toContain('-mt-6')
|
|
||||||
phone.unmount()
|
phone.unmount()
|
||||||
|
|
||||||
// The desktop and shared timelines keep their faint wash and the day-coloured pin.
|
// The desktop and shared timelines keep their faint wash and the day-coloured pin.
|
||||||
@@ -154,4 +153,12 @@ describe('JourneyEntryCover', () => {
|
|||||||
expect(pin.getAttribute('class')).not.toContain('-mt-6')
|
expect(pin.getAttribute('class')).not.toContain('-mt-6')
|
||||||
expect(pin.style.color).not.toBe('')
|
expect(pin.style.color).not.toBe('')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('fills a mobile card with its photo and draws the text in white', () => {
|
||||||
|
const { container } = render(<JourneyEntryCover entry={buildEntry()} dayColor="#6366f1" isActive onClick={() => {}} tone="mobile" />)
|
||||||
|
|
||||||
|
expect(container.querySelector('button')).toHaveClass('text-[color:var(--m-viewer-ink)]')
|
||||||
|
expect(container.querySelector('img[src*="/api/photos/"]')).toHaveClass('absolute', 'inset-0', 'size-full', 'object-cover')
|
||||||
|
expect(container.querySelector('.bg-gradient-to-t')).toBeInTheDocument()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,10 +20,8 @@ import type { JourneyEntry } from '../../store/journeyStore'
|
|||||||
* answers "how many stops into this day am I", which is not a question anyone
|
* answers "how many stops into this day am I", which is not a question anyone
|
||||||
* asks; the day scrubber above the carousel answers the one they do.
|
* asks; the day scrubber above the carousel answers the one they do.
|
||||||
*
|
*
|
||||||
* Two shells draw this card. `tone` picks the surface a card without a photo
|
* Photos fill the cover. The mobile shell uses a neutral card for entries
|
||||||
* falls back to, because the phone shell's tokens are scoped to `.m-root` and
|
* without a photo and a lighter active treatment over the map.
|
||||||
* the tablet timeline is outside it. Everything else is a photo and white text,
|
|
||||||
* which needs no tokens at all.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** A card's photo, plus what says whether a clip has a poster to draw (#2341). */
|
/** A card's photo, plus what says whether a clip has a poster to draw (#2341). */
|
||||||
@@ -82,7 +80,10 @@ export default function JourneyEntryCover({
|
|||||||
size = 'regular',
|
size = 'regular',
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const large = size === 'large'
|
const large = size === 'large'
|
||||||
const box = large ? 'h-[196px] w-[176px]' : size === 'compact' ? 'h-[112px] w-[124px]' : 'h-[152px] w-[136px]'
|
const mobile = tone === 'mobile'
|
||||||
|
const box = size === 'compact' ? 'h-[112px] w-[124px]'
|
||||||
|
: large ? (mobile ? 'h-[144px] w-[176px]' : 'h-[196px] w-[176px]')
|
||||||
|
: mobile ? 'h-[116px] w-[144px]' : 'h-[152px] w-[136px]'
|
||||||
const { t, locale } = useTranslation()
|
const { t, locale } = useTranslation()
|
||||||
const isSuggestion = entry.type === 'skeleton'
|
const isSuggestion = entry.type === 'skeleton'
|
||||||
|
|
||||||
@@ -100,12 +101,44 @@ export default function JourneyEntryCover({
|
|||||||
const mood = showMood ? moodMeta(entry.mood) : undefined
|
const mood = showMood ? moodMeta(entry.mood) : undefined
|
||||||
const weather = showWeather ? weatherMeta(entry.weather) : undefined
|
const weather = showWeather ? weatherMeta(entry.weather) : undefined
|
||||||
|
|
||||||
const mobile = tone === 'mobile'
|
if (mobile) {
|
||||||
const emptyGround = mobile ? 'bg-[color:var(--m-sheetop)]' : 'bg-white dark:bg-zinc-800'
|
return (
|
||||||
// The mark of a card without a photo: white and raised clear of the name on the
|
<button type="button" onClick={onClick} aria-current={isActive ? 'true' : undefined}
|
||||||
// phone's deep day colour, the day's own colour on the faint wash elsewhere.
|
className={`relative isolate flex ${box} flex-none origin-bottom flex-col justify-between overflow-hidden rounded-[18px] border bg-m-sheetop p-2.5 text-start shadow-sm transition-transform motion-reduce:transition-none ${src ? 'text-[color:var(--m-viewer-ink)]' : 'text-m-ink'} ${isActive ? 'z-[1] scale-[1.035]' : 'border-m-rowbr'}`}
|
||||||
const emptyIcon = mobile ? '-mt-6 opacity-80' : 'opacity-60'
|
style={isActive ? { borderColor: dayColor } : undefined}
|
||||||
const emptyIconStyle = mobile ? undefined : { color: dayColor }
|
>
|
||||||
|
{src && (
|
||||||
|
<>
|
||||||
|
<img src={src} alt="" loading="lazy" className="absolute inset-0 -z-10 size-full rounded-[inherit] object-cover" />
|
||||||
|
<span className="pointer-events-none absolute inset-x-0 bottom-0 -z-10 h-24 bg-gradient-to-t from-[color:var(--m-viewer-bg)] via-[color:var(--overlay)] to-transparent" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{isSuggestion && <span className="sr-only">{t('journey.entry.suggestion')}</span>}
|
||||||
|
<span className="flex w-full min-w-0 items-start justify-between gap-1.5">
|
||||||
|
<span className="flex min-w-0 flex-wrap items-center gap-1">
|
||||||
|
<span className={`whitespace-nowrap rounded-md px-1.5 py-0.5 text-caption font-medium ${src ? 'bg-[color:var(--overlay)]' : 'bg-m-ic text-m-muted'}`}>{date}</span>
|
||||||
|
{mood && <mood.icon size={12} style={{ color: mood.color }} />}
|
||||||
|
{weather && <weather.icon size={12} className={src ? undefined : 'text-m-muted'} />}
|
||||||
|
</span>
|
||||||
|
{posterless && (
|
||||||
|
<span className="grid h-9 w-12 flex-none place-items-center rounded-lg bg-m-ic text-m-muted">
|
||||||
|
<Play size={14} fill="currentColor" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="flex w-full min-w-0 flex-col gap-0.5">
|
||||||
|
<bdi className="line-clamp-2 text-control font-semibold leading-tight">{title}</bdi>
|
||||||
|
{place && (
|
||||||
|
<span className={`flex min-w-0 items-center gap-1 text-caption leading-snug ${src ? '' : 'text-m-muted'}`}>
|
||||||
|
{entry.country_code && <span className="flex-none"><CountryFlag code={entry.country_code} size={12} /></span>}
|
||||||
|
<bdi className="truncate">{place}</bdi>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// One ground for every corner mark. Dark rather than a white veil: these sit on
|
// One ground for every corner mark. Dark rather than a white veil: these sit on
|
||||||
// whatever photograph the traveller took, and a bright sky swallowed the white one.
|
// whatever photograph the traveller took, and a bright sky swallowed the white one.
|
||||||
const badge = 'rounded-full bg-black/45 px-[7px] py-[2px] text-[10px] font-bold whitespace-nowrap text-white backdrop-blur-[2px]'
|
const badge = 'rounded-full bg-black/45 px-[7px] py-[2px] text-[10px] font-bold whitespace-nowrap text-white backdrop-blur-[2px]'
|
||||||
@@ -123,11 +156,9 @@ export default function JourneyEntryCover({
|
|||||||
// growing its box moved every card after it once a swipe had landed, and the
|
// growing its box moved every card after it once a swipe had landed, and the
|
||||||
// snap then pulled the strip again, which read as a jolt (carousels keep the
|
// snap then pulled the strip again, which read as a jolt (carousels keep the
|
||||||
// room for it with their gap and top padding).
|
// room for it with their gap and top padding).
|
||||||
// White on the root: every mark and line on the card is white, over a photo or
|
|
||||||
// over the day's colour alike.
|
|
||||||
className={`relative text-white ${box} flex-none origin-bottom overflow-hidden rounded-[18px] text-start transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:transition-none ${
|
className={`relative text-white ${box} flex-none origin-bottom overflow-hidden rounded-[18px] text-start transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:transition-none ${
|
||||||
isActive ? 'z-[1] scale-[1.18] shadow-[0_18px_40px_-16px_rgba(0,0,0,.55)]' : 'scale-100 shadow-[0_10px_24px_-14px_rgba(0,0,0,.5)]'
|
isActive ? 'z-[1] scale-[1.18] shadow-[0_18px_40px_-16px_rgba(0,0,0,.55)]' : 'scale-100 shadow-[0_10px_24px_-14px_rgba(0,0,0,.5)]'
|
||||||
} ${src ? '' : emptyGround} ${isSuggestion && !mobile ? 'opacity-90' : ''}`}
|
} ${src ? '' : 'bg-white dark:bg-zinc-800'} ${isSuggestion ? 'opacity-90' : ''}`}
|
||||||
// backgroundImage, not background: the shorthand would drop the opaque colour
|
// backgroundImage, not background: the shorthand would drop the opaque colour
|
||||||
// the class supplies and leave the map showing through a card that is only a
|
// the class supplies and leave the map showing through a card that is only a
|
||||||
// faint wash of the day's colour.
|
// faint wash of the day's colour.
|
||||||
@@ -139,14 +170,7 @@ export default function JourneyEntryCover({
|
|||||||
// ring lost its top edge to that clip.
|
// ring lost its top edge to that clip.
|
||||||
style={{
|
style={{
|
||||||
boxShadow: `inset 0 0 0 ${isActive ? 2.5 : 1.5}px ${dayColor}${isActive ? '' : 'b3'}`,
|
boxShadow: `inset 0 0 0 ${isActive ? 2.5 : 1.5}px ${dayColor}${isActive ? '' : 'b3'}`,
|
||||||
// Without a photograph the phone's card is the day's colour, deep enough to
|
...(src ? null : { backgroundImage: `linear-gradient(160deg, ${dayColor}2e, ${dayColor}0d)` }),
|
||||||
// carry the white name like a photo does, rather than a grey that read as
|
|
||||||
// empty. Its ground stays opaque (no dimming for a suggestion either): it
|
|
||||||
// floats over the map, whose labels read through anything less. The desktop
|
|
||||||
// and shared timelines keep their faint wash of the day.
|
|
||||||
...(src ? null : { backgroundImage: mobile
|
|
||||||
? `linear-gradient(160deg, ${dayColor}d9, ${dayColor}8c 55%, ${dayColor}59)`
|
|
||||||
: `linear-gradient(160deg, ${dayColor}2e, ${dayColor}0d)` }),
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{src ? (
|
{src ? (
|
||||||
@@ -154,8 +178,8 @@ export default function JourneyEntryCover({
|
|||||||
) : (
|
) : (
|
||||||
<span className="absolute inset-0 flex items-center justify-center">
|
<span className="absolute inset-0 flex items-center justify-center">
|
||||||
{posterless
|
{posterless
|
||||||
? <Play size={24} strokeWidth={1.8} fill="currentColor" style={emptyIconStyle} className={`ml-0.5 ${emptyIcon}`} />
|
? <Play size={24} strokeWidth={1.8} fill="currentColor" className="ms-0.5 opacity-60" style={{ color: dayColor }} />
|
||||||
: <MapPin size={24} strokeWidth={1.8} style={emptyIconStyle} className={emptyIcon} />}
|
: <MapPin size={24} strokeWidth={1.8} className="opacity-60" style={{ color: dayColor }} />}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -196,7 +220,7 @@ export default function JourneyEntryCover({
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{weather && (
|
{weather && (
|
||||||
<span className={`${badgeDot}`}>
|
<span className={badgeDot}>
|
||||||
<weather.icon size={11} strokeWidth={2.4} />
|
<weather.icon size={11} strokeWidth={2.4} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useState, useEffect, useCallback, useRef } from 'react'
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
||||||
|
import { useOverlay } from '../../hooks/overlayStack'
|
||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import { ChevronLeft, ChevronRight, Loader2, X, ZoomIn, ZoomOut } from 'lucide-react'
|
import { ChevronLeft, ChevronRight, Loader2, X, ZoomIn, ZoomOut } from 'lucide-react'
|
||||||
import VideoPlayer from './VideoPlayerLazy'
|
import VideoPlayer from './VideoPlayerLazy'
|
||||||
@@ -53,6 +54,7 @@ const SAFE = (side: 'top' | 'bottom' | 'left' | 'right') =>
|
|||||||
`max(env(safe-area-inset-${side}, 0px), var(--safe-area-inset-${side}, 0px), var(--trek-native-safe-${side}, 0px))`
|
`max(env(safe-area-inset-${side}, 0px), var(--safe-area-inset-${side}, 0px), var(--trek-native-safe-${side}, 0px))`
|
||||||
|
|
||||||
export default function PhotoLightbox({ photos, startIndex = 0, onClose, label }: Props) {
|
export default function PhotoLightbox({ photos, startIndex = 0, onClose, label }: Props) {
|
||||||
|
useOverlay(true, onClose, true)
|
||||||
const [idx, setIdx] = useState(startIndex)
|
const [idx, setIdx] = useState(startIndex)
|
||||||
const touchStart = useRef<{ x: number; y: number } | null>(null)
|
const touchStart = useRef<{ x: number; y: number } | null>(null)
|
||||||
const dialogRef = useRef<HTMLDivElement>(null)
|
const dialogRef = useRef<HTMLDivElement>(null)
|
||||||
@@ -87,13 +89,12 @@ export default function PhotoLightbox({ photos, startIndex = 0, onClose, label }
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onKey = (e: KeyboardEvent) => {
|
const onKey = (e: KeyboardEvent) => {
|
||||||
if (e.key === 'Escape') onClose()
|
|
||||||
if (e.key === 'ArrowLeft') (rtl ? next : prev)()
|
if (e.key === 'ArrowLeft') (rtl ? next : prev)()
|
||||||
if (e.key === 'ArrowRight') (rtl ? prev : next)()
|
if (e.key === 'ArrowRight') (rtl ? prev : next)()
|
||||||
}
|
}
|
||||||
window.addEventListener('keydown', onKey)
|
window.addEventListener('keydown', onKey)
|
||||||
return () => window.removeEventListener('keydown', onKey)
|
return () => window.removeEventListener('keydown', onKey)
|
||||||
}, [prev, next, onClose, rtl])
|
}, [prev, next, rtl])
|
||||||
|
|
||||||
// A pinch, a double tap or a pan of an enlarged photo belongs to the zoom; only
|
// A pinch, a double tap or a pan of an enlarged photo belongs to the zoom; only
|
||||||
// the rest is a swipe that turns the page or closes the lightbox.
|
// the rest is a swipe that turns the page or closes the lightbox.
|
||||||
|
|||||||
@@ -168,8 +168,8 @@ export function useJourneySettings({ journey, onSaved, onRefresh, onContentChang
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveContributor = async (c: JourneyContributor) => {
|
const handleRemoveContributor = async (c: JourneyContributor, confirmed = false) => {
|
||||||
if (!window.confirm(t('journey.contributors.removeConfirm', { username: c.username }))) return;
|
if (!confirmed && !window.confirm(t('journey.contributors.removeConfirm', { username: c.username }))) return;
|
||||||
try {
|
try {
|
||||||
await journeyApi.removeContributor(journey.id, c.user_id);
|
await journeyApi.removeContributor(journey.id, c.user_id);
|
||||||
toast.success(t('journey.contributors.removed'));
|
toast.success(t('journey.contributors.removed'));
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ describe('splitMobileNav', () => {
|
|||||||
it('docks the top two enabled defaults when there is no config', () => {
|
it('docks the top two enabled defaults when there is no config', () => {
|
||||||
for (const cfg of [undefined, { bar: [], more: [] }]) {
|
for (const cfg of [undefined, { bar: [], more: [] }]) {
|
||||||
const s = splitMobileNav(items, cfg)
|
const s = splitMobileNav(items, cfg)
|
||||||
expect(ids(s.bar)).toEqual(['dashboard', 'vacay', 'journey'])
|
expect(ids(s.bar)).toEqual(['dashboard', 'collections', 'journey'])
|
||||||
// Atlas is still reachable, one tap further under More.
|
// Atlas is still reachable, one tap further under More.
|
||||||
expect(ids(s.more)).toEqual(['atlas', 'collections'])
|
expect(ids(s.more)).toEqual(['vacay', 'atlas'])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -41,25 +41,20 @@ const ADDON_ICONS: Record<string, LucideIcon> = {
|
|||||||
/** The bar holds Dashboard + at most this many custom items; the rest go to More.
|
/** The bar holds Dashboard + at most this many custom items; the rest go to More.
|
||||||
* Two keeps the dock at 3 entries (Dashboard + 2) so the More slot still fits. */
|
* Two keeps the dock at 3 entries (Dashboard + 2) so the More slot still fits. */
|
||||||
export const MOBILE_NAV_MAX_BAR = 2
|
export const MOBILE_NAV_MAX_BAR = 2
|
||||||
/**
|
|
||||||
* The built-in dock next to Dashboard for an un-customised account, in priority
|
|
||||||
* order: the first MOBILE_NAV_MAX_BAR of these that are actually enabled take the
|
|
||||||
* slots, everything else starts under More.
|
|
||||||
*
|
|
||||||
* Journey outranks Atlas because a phone in the field wants the journal it writes
|
|
||||||
* to every day, not the map of countries it already visited. Journey ships
|
|
||||||
* disabled though, so an instance that never turned it on keeps the Vacay/Atlas
|
|
||||||
* dock it has today. Listing all four known global addons rather than just the
|
|
||||||
* top two also keeps the dock filled when one of them is switched off. The
|
|
||||||
* assistant comes last: it takes a slot only one of the addons left free, rather
|
|
||||||
* than sitting alone behind the More button.
|
|
||||||
*/
|
|
||||||
/** Where an addon's page lives: its id, except Collections, which became Places (PLC-07). */
|
/** Where an addon's page lives: its id, except Collections, which became Places (PLC-07). */
|
||||||
export function addonPath(id: string): string {
|
export function addonPath(id: string): string {
|
||||||
return id === 'collections' ? '/places' : `/${id}`
|
return id === 'collections' ? '/places' : `/${id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_DOCK_IDS = ['vacay', 'journey', 'atlas', 'collections', ASSISTANT_NAV_ID]
|
/**
|
||||||
|
* The built-in dock next to Dashboard for an un-customised account, in priority
|
||||||
|
* order: the first MOBILE_NAV_MAX_BAR of these that are actually enabled take the
|
||||||
|
* slots, everything else starts under More.
|
||||||
|
*
|
||||||
|
* Places and Journey sit beside trips when enabled. The remaining enabled
|
||||||
|
* destinations fill unused slots, and the customizer keeps saved choices.
|
||||||
|
*/
|
||||||
|
export const DEFAULT_DOCK_IDS = ['collections', 'journey', 'vacay', 'atlas', ASSISTANT_NAV_ID]
|
||||||
|
|
||||||
export function buildNavItems(
|
export function buildNavItems(
|
||||||
globalAddons: { id: string; name: string; icon: string }[],
|
globalAddons: { id: string; name: string; icon: string }[],
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ import { useToast } from '../shared/Toast';
|
|||||||
* own address; it is the person's own, so a fellow traveller gets another.
|
* own address; it is the person's own, so a fellow traveller gets another.
|
||||||
* Nothing where the import is off for the person.
|
* Nothing where the import is off for the person.
|
||||||
*/
|
*/
|
||||||
export default function TripMailForward({ tripId }: { tripId: number }): ReactElement | null {
|
export default function TripMailForward({
|
||||||
|
tripId,
|
||||||
|
mobile = false,
|
||||||
|
}: {
|
||||||
|
tripId: number;
|
||||||
|
mobile?: boolean;
|
||||||
|
}): ReactElement | null {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const settings = useMailIngestStore((s) => s.settings);
|
const settings = useMailIngestStore((s) => s.settings);
|
||||||
@@ -62,7 +68,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-1 flex flex-col gap-2 rounded-xl bg-surface-tertiary px-3.5 py-3">
|
<div className={`mt-1 flex flex-col gap-2 rounded-xl px-3.5 py-3 ${mobile ? 'bg-m-ic' : 'bg-surface-tertiary'}`}>
|
||||||
<div className="flex items-center gap-2 text-body font-semibold text-content">
|
<div className="flex items-center gap-2 text-body font-semibold text-content">
|
||||||
<Mail size={15} strokeWidth={2} className="text-content-muted" />
|
<Mail size={15} strokeWidth={2} className="text-content-muted" />
|
||||||
{t('mailInbox.trip.title')}
|
{t('mailInbox.trip.title')}
|
||||||
@@ -72,7 +78,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
|
|||||||
<div className="flex min-w-0 items-center gap-2">
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
<code
|
<code
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
className="min-w-0 flex-1 truncate rounded-lg bg-surface-card px-2.5 py-1.5 font-geist text-caption text-content"
|
className={`min-w-0 flex-1 truncate rounded-lg px-2.5 py-1.5 font-geist text-caption text-content ${mobile ? 'bg-m-sheetop' : 'bg-surface-card'}`}
|
||||||
>
|
>
|
||||||
{address.address}
|
{address.address}
|
||||||
</code>
|
</code>
|
||||||
@@ -80,7 +86,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() => void copy()}
|
onClick={() => void copy()}
|
||||||
aria-label={t('mailInbox.settings.copy')}
|
aria-label={t('mailInbox.settings.copy')}
|
||||||
className="grid h-8 w-8 flex-none place-items-center rounded-lg bg-surface-card text-content-muted hover:text-content"
|
className={`grid flex-none place-items-center rounded-lg text-content-muted hover:text-content ${mobile ? 'size-11 bg-m-sheetop' : 'size-8 bg-surface-card'}`}
|
||||||
>
|
>
|
||||||
<Copy size={14} strokeWidth={2} />
|
<Copy size={14} strokeWidth={2} />
|
||||||
</button>
|
</button>
|
||||||
@@ -90,7 +96,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() => void create()}
|
onClick={() => void create()}
|
||||||
disabled={creating}
|
disabled={creating}
|
||||||
className="inline-flex w-fit items-center gap-1.5 rounded-lg bg-surface-card px-3 py-1.5 text-caption font-semibold text-content hover:bg-surface-hover disabled:opacity-50"
|
className={`inline-flex w-fit items-center gap-1.5 rounded-lg px-3 py-1.5 text-caption font-semibold text-content hover:bg-surface-hover disabled:opacity-50 ${mobile ? 'min-h-11 bg-m-sheetop' : 'bg-surface-card'}`}
|
||||||
>
|
>
|
||||||
<Plus size={13} strokeWidth={2.2} />
|
<Plus size={13} strokeWidth={2.2} />
|
||||||
{t('mailInbox.trip.create')}
|
{t('mailInbox.trip.create')}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { Type } from 'lucide-react';
|
import { Type } from 'lucide-react';
|
||||||
import { useTranslation } from '../../i18n';
|
import { useTranslation } from '../../i18n';
|
||||||
import { useSettingsStore } from '../../store/settingsStore';
|
|
||||||
import { useToast } from '../shared/Toast';
|
|
||||||
import { MapTogglePill } from './MapTogglePill';
|
import { MapTogglePill } from './MapTogglePill';
|
||||||
import { usePlaceNamesSetting } from './usePlaceNameLayout';
|
import { usePlaceNamesToggle } from './usePlaceNameLayout';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns the place names beside the trip map's pins on and off (#2796). The choice is
|
* Turns the place names beside the trip map's pins on and off (#2796). The choice is
|
||||||
@@ -11,23 +9,12 @@ import { usePlaceNamesSetting } from './usePlaceNameLayout';
|
|||||||
*/
|
*/
|
||||||
export function PlaceNamesPill() {
|
export function PlaceNamesPill() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const on = usePlaceNamesSetting();
|
const { on, setOn } = usePlaceNamesToggle();
|
||||||
const updateSetting = useSettingsStore((s) => s.updateSetting);
|
|
||||||
const toast = useToast();
|
|
||||||
// The switch flips at once; a save that fails turns it back and says so.
|
|
||||||
const toggle = async () => {
|
|
||||||
try {
|
|
||||||
await updateSetting('map_place_labels', !on);
|
|
||||||
} catch (err) {
|
|
||||||
useSettingsStore.setState((s) => ({ settings: { ...s.settings, map_place_labels: on } }));
|
|
||||||
toast.error(err instanceof Error ? err.message : t('common.error'));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<MapTogglePill
|
<MapTogglePill
|
||||||
active={on}
|
active={on}
|
||||||
onToggle={() => {
|
onToggle={() => {
|
||||||
void toggle();
|
void setOn(!on);
|
||||||
}}
|
}}
|
||||||
label={on ? t('map.placeNames.hide') : t('map.placeNames.show')}
|
label={on ? t('map.placeNames.hide') : t('map.placeNames.show')}
|
||||||
testId="place-names-pill"
|
testId="place-names-pill"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { withHotelBookends } from './RouteCalculator'
|
import { withHotelBookends } from './RouteCalculator'
|
||||||
import { getTransportRouteEndpoints, getTransportForDay, getMergedItems, isCarrierTransport, hasCarrierEndpointOnDay } from '../../utils/dayMerge'
|
import { getSpanPhase, getTransportRouteEndpoints, getTransportForDay, getMergedItems, isCarrierTransport, hasCarrierEndpointOnDay, stopDayIds } from '../../utils/dayMerge'
|
||||||
import { getDayBookendHotels, shouldDrawMorningLeg, shouldDrawEveningLeg, type CarrierEdge } from '../../utils/dayOrder'
|
import { getDayBookendHotels, shouldDrawMorningLeg, shouldDrawEveningLeg, type CarrierEdge } from '../../utils/dayOrder'
|
||||||
import { withinDriveRange } from '@trek/shared/roadtrip'
|
import { withinDriveRange } from '@trek/shared/roadtrip'
|
||||||
import type { Accommodation, AssignmentsMap, Day, Place, Reservation } from '../../types'
|
import type { Accommodation, AssignmentsMap, Day, Place, Reservation } from '../../types'
|
||||||
@@ -43,6 +43,15 @@ export interface DayRouteInputs {
|
|||||||
places?: Place[]
|
places?: Place[]
|
||||||
/** MDT-02: where the stages of the trip's multi-day tours run, so a day holding one routes to it. */
|
/** MDT-02: where the stages of the trip's multi-day tours run, so a day holding one routes to it. */
|
||||||
tourStageStops?: TourStageStops
|
tourStageStops?: TourStageStops
|
||||||
|
includeLocatedBookings?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A reservation linked to a place can be a stop in the itinerary without being a transport leg. */
|
||||||
|
export function locatedBookingWaypoint(reservation: Reservation, dayId: number, places?: readonly Place[]) {
|
||||||
|
if (reservation.place_id == null || reservation.type === 'hotel' || TRANSPORT_TYPES.includes(reservation.type)
|
||||||
|
|| getSpanPhase(reservation, dayId) === 'middle') return null
|
||||||
|
const place = places?.find(candidate => candidate.id === reservation.place_id)
|
||||||
|
return place && place.lat != null && place.lng != null ? { lat: place.lat, lng: place.lng } : null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,16 +88,18 @@ export function buildDayRouteRuns(dayId: number, input: DayRouteInputs): DayRout
|
|||||||
// it; getMergedItems places each leg by its own saved position, falling back to its
|
// it; getMergedItems places each leg by its own saved position, falling back to its
|
||||||
// time. Notes carry no coordinates, so none are passed.
|
// time. Notes carry no coordinates, so none are passed.
|
||||||
const dayTransports = thisOrder == null ? [] : getTransportForDay({
|
const dayTransports = thisOrder == null ? [] : getTransportForDay({
|
||||||
reservations: allReservations.filter(r => TRANSPORT_TYPES.includes(r.type)),
|
reservations: allReservations.filter(r => TRANSPORT_TYPES.includes(r.type)
|
||||||
|
|| (input.includeLocatedBookings && !!locatedBookingWaypoint(r, dayId, input.places))),
|
||||||
dayId,
|
dayId,
|
||||||
dayAssignmentIds: da.map(a => a.id),
|
dayAssignmentIds: da.map(a => a.id),
|
||||||
days: allDays,
|
days: allDays,
|
||||||
|
stopDays: input.includeLocatedBookings ? stopDayIds(assignments) : undefined,
|
||||||
})
|
})
|
||||||
const merged = getMergedItems({ dayAssignments: da, dayNotes: [], dayTransports, dayId })
|
const merged = getMergedItems({ dayAssignments: da, dayNotes: [], dayTransports, dayId })
|
||||||
const projected = projectedById(da, input.toursEnabled ?? false, input.places, input.tourStageStops)
|
const projected = projectedById(da, input.toursEnabled ?? false, input.places, input.tourStageStops)
|
||||||
|
|
||||||
type Entry =
|
type Entry =
|
||||||
| { kind: 'place'; id: number; lat: number; lng: number; pos: number; time: string | null; mode: string | null; incoming: string | null }
|
| { kind: 'place'; id?: number; lat: number; lng: number; pos: number; time: string | null; mode: string | null; incoming: string | null }
|
||||||
| { kind: 'tour'; start: { lat: number; lng: number } | null; end: { lat: number; lng: number } | null; pos: number; time: string | null; mode: string | null; incoming: string | null }
|
| { kind: 'tour'; start: { lat: number; lng: number } | null; end: { lat: number; lng: number } | null; pos: number; time: string | null; mode: string | null; incoming: string | null }
|
||||||
| { kind: 'transport'; from: { lat: number; lng: number } | null; to: { lat: number; lng: number } | null; pos: number; carrier: boolean }
|
| { kind: 'transport'; from: { lat: number; lng: number } | null; to: { lat: number; lng: number } | null; pos: number; carrier: boolean }
|
||||||
const entries: Entry[] = merged.flatMap((item): Entry[] => {
|
const entries: Entry[] = merged.flatMap((item): Entry[] => {
|
||||||
@@ -111,6 +122,8 @@ export function buildDayRouteRuns(dayId: number, input: DayRouteInputs): DayRout
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
if (item.type !== 'transport') return []
|
if (item.type !== 'transport') return []
|
||||||
|
const booking = input.includeLocatedBookings ? locatedBookingWaypoint(item.data, dayId, input.places) : null
|
||||||
|
if (booking) return [{ kind: 'place', ...booking, pos: item.sortKey, time: null, mode: null, incoming: null }]
|
||||||
const { from, to } = getTransportRouteEndpoints(item.data, dayId)
|
const { from, to } = getTransportRouteEndpoints(item.data, dayId)
|
||||||
return [{ kind: 'transport', from, to, pos: item.sortKey, carrier: isCarrierTransport(item.data) }]
|
return [{ kind: 'transport', from, to, pos: item.sortKey, carrier: isCarrierTransport(item.data) }]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
|
import { useTranslation } from '../../i18n';
|
||||||
import { useSettingsStore } from '../../store/settingsStore';
|
import { useSettingsStore } from '../../store/settingsStore';
|
||||||
|
import { useToast } from '../shared/Toast';
|
||||||
import { controlBoxes, layoutPlaceNames, PLACE_NAMES_CONTROLS } from './placeNameLabels';
|
import { controlBoxes, layoutPlaceNames, PLACE_NAMES_CONTROLS } from './placeNameLabels';
|
||||||
|
|
||||||
/** Whether the trip map shows its place names, the reader's own setting (#2796). */
|
/** Whether the trip map shows its place names, the reader's own setting (#2796). */
|
||||||
@@ -8,6 +10,23 @@ export function usePlaceNamesSetting(): boolean {
|
|||||||
return useSettingsStore((s) => s.settings.map_place_labels) === true;
|
return useSettingsStore((s) => s.settings.map_place_labels) === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Flips the reader's label setting at once and restores it if saving fails. */
|
||||||
|
export function usePlaceNamesToggle() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const on = usePlaceNamesSetting();
|
||||||
|
const updateSetting = useSettingsStore((s) => s.updateSetting);
|
||||||
|
const toast = useToast();
|
||||||
|
const setOn = async (value: boolean) => {
|
||||||
|
try {
|
||||||
|
await updateSetting('map_place_labels', value);
|
||||||
|
} catch (err) {
|
||||||
|
useSettingsStore.setState((s) => ({ settings: { ...s.settings, map_place_labels: on } }));
|
||||||
|
toast.error(err instanceof Error ? err.message : t('common.error'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return { on, setOn };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps the place names of one map laid out: once after every change of the markers
|
* Keeps the place names of one map laid out: once after every change of the markers
|
||||||
* (a cluster opening, a day picked) and after every move or zoom the renderer reports
|
* (a cluster opening, a day picked) and after every move or zoom the renderer reports
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ interface KategorieGruppeProps {
|
|||||||
onRename: (oldName: string, newName: string) => Promise<void>
|
onRename: (oldName: string, newName: string) => Promise<void>
|
||||||
onDeleteAll: (items: PackingItem[]) => Promise<void>
|
onDeleteAll: (items: PackingItem[]) => Promise<void>
|
||||||
onDeleteItem: (item: PackingItem) => Promise<void>
|
onDeleteItem: (item: PackingItem) => Promise<void>
|
||||||
onAddItem: (category: string, name: string) => Promise<void>
|
onAddItem: (category: string, name: string) => Promise<unknown>
|
||||||
assignees: CategoryAssignee[]
|
assignees: CategoryAssignee[]
|
||||||
tripMembers: TripMember[]
|
tripMembers: TripMember[]
|
||||||
onSetAssignees: (category: string, userIds: number[]) => Promise<void>
|
onSetAssignees: (category: string, userIds: number[]) => Promise<void>
|
||||||
|
|||||||
@@ -80,6 +80,19 @@ describe('usePackingItemActions', () => {
|
|||||||
expect(phone.acts.addPackingItem).toHaveBeenCalledWith(7, { name: 'Tent', category: 'Camp', visibility: 'common' });
|
expect(phone.acts.addPackingItem).toHaveBeenCalledWith(7, { name: 'Tent', category: 'Camp', visibility: 'common' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('uses the personal placeholder when both scopes have the same category name', async () => {
|
||||||
|
const shared = buildPackingItem({ id: 4, name: PACKING_PLACEHOLDER_NAME, category: 'Camp' });
|
||||||
|
const personal = buildPackingItem({ ...shared, id: 5, is_private: 1, owner_id: 9 });
|
||||||
|
const { result, acts } = setup({ items: [shared, personal], view: 'personal' });
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
await result.current.addItemToCategory('Camp', 'Tent');
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(acts.updatePackingItem).toHaveBeenCalledWith(7, 5, { name: 'Tent' });
|
||||||
|
expect(acts.updatePackingItem).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
|
||||||
it('FE-PACK-ITEMACT-003: in my list a new item is shared the way the category already is (#2241)', async () => {
|
it('FE-PACK-ITEMACT-003: in my list a new item is shared the way the category already is (#2241)', async () => {
|
||||||
const own = buildPackingItem({
|
const own = buildPackingItem({
|
||||||
id: 5,
|
id: 5,
|
||||||
|
|||||||
@@ -57,13 +57,18 @@ export function usePackingItemActions({
|
|||||||
const [addingCategory, setAddingCategory] = useState(false);
|
const [addingCategory, setAddingCategory] = useState(false);
|
||||||
const [newCategoryName, setNewCategoryName] = useState('');
|
const [newCategoryName, setNewCategoryName] = useState('');
|
||||||
|
|
||||||
const addItemToCategory = async (category: string, name: string) => {
|
const addItemToCategory = async (category: string | null, name: string) => {
|
||||||
try {
|
try {
|
||||||
// Reuse the '...' placeholder slot when the category already has one, so a
|
// Reuse the '...' placeholder slot when the category already has one, so a
|
||||||
// freshly-emptied category keeps its position (and therefore its colour)
|
// freshly-emptied category keeps its position (and therefore its colour)
|
||||||
// instead of the new item being appended to the end of the list.
|
// instead of the new item being appended to the end of the list.
|
||||||
const pool = placeholderFrom === 'store' ? useTripStore.getState().packingItems : items;
|
const pool = placeholderFrom === 'store' ? useTripStore.getState().packingItems : items;
|
||||||
const placeholder = pool.find((i) => i.category === category && isPackingPlaceholder(i));
|
const placeholder = packingViewItems(pool, view).find(
|
||||||
|
(i) =>
|
||||||
|
(i.category || null) === category &&
|
||||||
|
isPackingPlaceholder(i) &&
|
||||||
|
(view === 'common' || i.owner_id == null || i.owner_id === currentUserId)
|
||||||
|
);
|
||||||
if (placeholder) {
|
if (placeholder) {
|
||||||
await updatePackingItem(tripId, placeholder.id, { name });
|
await updatePackingItem(tripId, placeholder.id, { name });
|
||||||
} else {
|
} else {
|
||||||
@@ -71,12 +76,13 @@ export function usePackingItemActions({
|
|||||||
// category's own items agree on (#2241).
|
// category's own items agree on (#2241).
|
||||||
await addPackingItem(tripId, {
|
await addPackingItem(tripId, {
|
||||||
name,
|
name,
|
||||||
category,
|
...(category ? { category, ...newItemSharing(items, category, view, currentUserId) } : { visibility: view }),
|
||||||
...newItemSharing(items, category, view, currentUserId),
|
|
||||||
} as Parameters<typeof addPackingItem>[1]);
|
} as Parameters<typeof addPackingItem>[1]);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(t('packing.toast.addError'));
|
toast.error(t('packing.toast.addError'));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,7 +94,7 @@ export function usePackingItemActions({
|
|||||||
// removing the placeholder is how an empty category is dismissed.
|
// removing the placeholder is how an empty category is dismissed.
|
||||||
const deleteItem = async (item: PackingItem) => {
|
const deleteItem = async (item: PackingItem) => {
|
||||||
try {
|
try {
|
||||||
if (isLastCustomItemInCategory(item, items)) {
|
if (isLastCustomItemInCategory(item, packingViewItems(items, item.is_private ? 'personal' : 'common'))) {
|
||||||
if (item.checked) await togglePackingItem(tripId, item.id, false);
|
if (item.checked) await togglePackingItem(tripId, item.id, false);
|
||||||
await updatePackingItem(tripId, item.id, {
|
await updatePackingItem(tripId, item.id, {
|
||||||
name: PACKING_PLACEHOLDER_NAME,
|
name: PACKING_PLACEHOLDER_NAME,
|
||||||
@@ -106,7 +112,7 @@ export function usePackingItemActions({
|
|||||||
|
|
||||||
/** Moves every item of a category to the new name, one write each; a failure stops it and is thrown. */
|
/** Moves every item of a category to the new name, one write each; a failure stops it and is thrown. */
|
||||||
const renameCategory = async (oldName: string, newName: string) => {
|
const renameCategory = async (oldName: string, newName: string) => {
|
||||||
const toUpdate = items.filter((i) => (i.category || defaultCategory) === oldName);
|
const toUpdate = packingViewItems(items, view).filter((i) => (i.category || defaultCategory) === oldName);
|
||||||
for (const item of toUpdate) {
|
for (const item of toUpdate) {
|
||||||
await updatePackingItem(tripId, item.id, { category: newName });
|
await updatePackingItem(tripId, item.id, { category: newName });
|
||||||
}
|
}
|
||||||
@@ -136,7 +142,7 @@ export function usePackingItemActions({
|
|||||||
/** Removes the checked items of the open view only, the ones the button's count names. */
|
/** Removes the checked items of the open view only, the ones the button's count names. */
|
||||||
const clearChecked = async () => {
|
const clearChecked = async () => {
|
||||||
let failed = false;
|
let failed = false;
|
||||||
for (const item of packingViewItems(items, view).filter((i) => i.checked)) {
|
for (const item of packingViewItems(items, view).filter((i) => i.checked && !isPackingPlaceholder(i))) {
|
||||||
try {
|
try {
|
||||||
await deletePackingItem(tripId, item.id);
|
await deletePackingItem(tripId, item.id);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { useBackgroundTasksStore } from '../../store/backgroundTasksStore';
|
|||||||
import { resetAllStores } from '../../../tests/helpers/store';
|
import { resetAllStores } from '../../../tests/helpers/store';
|
||||||
import { saveImportFiles } from '../../db/offlineDb';
|
import { saveImportFiles } from '../../db/offlineDb';
|
||||||
import BookingImportModal from './BookingImportModal';
|
import BookingImportModal from './BookingImportModal';
|
||||||
|
import MBookingImportSheet from '../../mobile/screens/trip/sheets/MBookingImportSheet';
|
||||||
|
|
||||||
vi.mock('../../db/offlineDb', () => ({ saveImportFiles: vi.fn(async () => {}) }));
|
vi.mock('../../db/offlineDb', () => ({ saveImportFiles: vi.fn(async () => {}) }));
|
||||||
|
|
||||||
@@ -36,6 +37,32 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('BookingImportModal', () => {
|
describe('BookingImportModal', () => {
|
||||||
|
it('uploads the selected mobile PDF once and keeps it for the booking review', async () => {
|
||||||
|
const onClose = vi.fn();
|
||||||
|
const pdf = new File(['%PDF-1.4'], 'booking.pdf', { type: 'application/pdf' });
|
||||||
|
const upload = vi.fn(() => HttpResponse.json({ jobId: 'mobile-pdf' }));
|
||||||
|
server.use(http.post('/api/trips/4/reservations/import/booking/async', upload));
|
||||||
|
render(<MBookingImportSheet {...defaultProps} kind="bookings" onClose={onClose} />);
|
||||||
|
expect(screen.getByRole('dialog', { name: 'Import from file' })).toBeInTheDocument();
|
||||||
|
await userEvent.upload(fileInput(), [pdf, eml()]);
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: 'Remove: booking.eml' }));
|
||||||
|
const submit = screen.getByRole('button', { name: 'Import' });
|
||||||
|
await waitFor(() => expect(submit).toBeEnabled());
|
||||||
|
await userEvent.click(submit);
|
||||||
|
await waitFor(() => expect(onClose).toHaveBeenCalledOnce());
|
||||||
|
expect(upload).toHaveBeenCalledOnce();
|
||||||
|
expect(saveImportFiles).toHaveBeenCalledWith('mobile-pdf', [pdf]);
|
||||||
|
expect(useBackgroundTasksStore.getState().tasks.find(task => task.id === 'mobile-pdf'))
|
||||||
|
.toMatchObject({ kind: 'bookings', total: 1 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('opens the mobile dialog with an explanation if the server has no parser', async () => {
|
||||||
|
server.use(http.get('/api/health/features', () => HttpResponse.json({ bookingImport: false, aiParsing: false })));
|
||||||
|
render(<MBookingImportSheet {...defaultProps} />);
|
||||||
|
expect(await screen.findByText(/import is not available on this server/i)).toBeInTheDocument();
|
||||||
|
expect(screen.queryByRole('button', { name: 'Import' })).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it('FE-PLANNER-BOOKIMP-001: renders nothing while closed', () => {
|
it('FE-PLANNER-BOOKIMP-001: renders nothing while closed', () => {
|
||||||
render(<BookingImportModal {...defaultProps} isOpen={false} />);
|
render(<BookingImportModal {...defaultProps} isOpen={false} />);
|
||||||
expect(screen.queryByText('Import booking confirmations')).not.toBeInTheDocument();
|
expect(screen.queryByText('Import booking confirmations')).not.toBeInTheDocument();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import { useSharedImportStore } from '../../native/sharedFiles'
|
import { useSharedImportStore } from '../../native/sharedFiles'
|
||||||
import { useState, useRef, useEffect } from 'react'
|
import { useState, useRef, useEffect, type ReactNode, type DragEventHandler } from 'react'
|
||||||
import { Upload, X } from 'lucide-react'
|
import { Upload, X } from 'lucide-react'
|
||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
import { reservationsApi, healthApi } from '../../api/client'
|
import { reservationsApi, healthApi } from '../../api/client'
|
||||||
@@ -11,13 +11,34 @@ import { saveImportFiles } from '../../db/offlineDb'
|
|||||||
import { isEffectivelyOffline } from '../../sync/networkMode'
|
import { isEffectivelyOffline } from '../../sync/networkMode'
|
||||||
import TripMailForward from '../MailIngest/TripMailForward'
|
import TripMailForward from '../MailIngest/TripMailForward'
|
||||||
|
|
||||||
interface BookingImportModalProps {
|
export interface BookingImportModalProps {
|
||||||
isOpen: boolean
|
isOpen: boolean
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
tripId: number
|
tripId: number
|
||||||
/** The tab this import was started from, carried into the job so the review
|
/** The tab this import was started from, carried into the job so the review
|
||||||
* can pick the right form for an item whose type had to be guessed (#2076). */
|
* can pick the right form for an item whose type had to be guessed (#2076). */
|
||||||
kind?: 'transports' | 'bookings'
|
kind?: 'transports' | 'bookings'
|
||||||
|
renderContent?: (view: BookingImportView) => ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BookingImportView {
|
||||||
|
tripId: number
|
||||||
|
files: File[]
|
||||||
|
fileInput: ReactNode
|
||||||
|
pickFiles: () => void
|
||||||
|
removeFile: (index: number) => void
|
||||||
|
dragHandlers: {
|
||||||
|
onDragOver: DragEventHandler
|
||||||
|
onDragLeave: DragEventHandler
|
||||||
|
onDrop: DragEventHandler
|
||||||
|
}
|
||||||
|
isDragOver: boolean
|
||||||
|
loading: boolean
|
||||||
|
error: string
|
||||||
|
available: boolean | null
|
||||||
|
readsPhotos: boolean
|
||||||
|
handleClose: () => void
|
||||||
|
handleParse: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
const ACCEPTED_EXTS = ['.eml', '.pdf', '.pkpass', '.html', '.htm', '.txt']
|
const ACCEPTED_EXTS = ['.eml', '.pdf', '.pkpass', '.html', '.htm', '.txt']
|
||||||
@@ -30,7 +51,7 @@ const MAX_FILES = 5
|
|||||||
* (progress over the WebSocket). When it finishes, the trip page opens the per-item
|
* (progress over the WebSocket). When it finishes, the trip page opens the per-item
|
||||||
* review flow — so the user can navigate and keep editing while it works.
|
* review flow — so the user can navigate and keep editing while it works.
|
||||||
*/
|
*/
|
||||||
export default function BookingImportModal({ isOpen, onClose, tripId, kind }: BookingImportModalProps) {
|
export default function BookingImportModal({ isOpen, onClose, tripId, kind, renderContent }: BookingImportModalProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const addTask = useBackgroundTasksStore((s) => s.addTask)
|
const addTask = useBackgroundTasksStore((s) => s.addTask)
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||||
@@ -44,6 +65,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo
|
|||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const [aiParsing, setAiParsing] = useState(false)
|
const [aiParsing, setAiParsing] = useState(false)
|
||||||
|
const [uploadAvailable, setUploadAvailable] = useState<boolean | null>(null)
|
||||||
const [readsPhotos, setReadsPhotos] = useState(false)
|
const [readsPhotos, setReadsPhotos] = useState(false)
|
||||||
// Only a model that reads images can do anything with a photo, so photos are offered only then.
|
// Only a model that reads images can do anything with a photo, so photos are offered only then.
|
||||||
const acceptedExts: readonly string[] = readsPhotos ? [...ACCEPTED_EXTS, ...LLM_PHOTO_EXTENSIONS] : ACCEPTED_EXTS
|
const acceptedExts: readonly string[] = readsPhotos ? [...ACCEPTED_EXTS, ...LLM_PHOTO_EXTENSIONS] : ACCEPTED_EXTS
|
||||||
@@ -60,6 +82,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo
|
|||||||
setIsDragOver(false)
|
setIsDragOver(false)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
setError('')
|
setError('')
|
||||||
|
setUploadAvailable(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +95,22 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen) return
|
if (!isOpen) return
|
||||||
healthApi.features().then((f) => setAiParsing(!!f.aiParsing)).catch(() => setAiParsing(false))
|
let active = true
|
||||||
llmRepo.readsPhotos().then(setReadsPhotos).catch(() => setReadsPhotos(false))
|
healthApi.features().then((f) => {
|
||||||
|
if (!active) return
|
||||||
|
setAiParsing(!!f.aiParsing)
|
||||||
|
setUploadAvailable(!!(f.bookingImport || f.aiParsing))
|
||||||
|
}).catch(() => {
|
||||||
|
if (!active) return
|
||||||
|
setAiParsing(false)
|
||||||
|
// Let the import endpoint report a connection or capability error if the feature check fails.
|
||||||
|
setUploadAvailable(true)
|
||||||
|
})
|
||||||
|
llmRepo.readsPhotos().then(
|
||||||
|
(supported) => { if (active) setReadsPhotos(supported) },
|
||||||
|
() => { if (active) setReadsPhotos(false) }
|
||||||
|
)
|
||||||
|
return () => { active = false }
|
||||||
}, [isOpen])
|
}, [isOpen])
|
||||||
|
|
||||||
const handleClose = () => { reset(); onClose() }
|
const handleClose = () => { reset(); onClose() }
|
||||||
@@ -115,7 +152,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo
|
|||||||
|
|
||||||
// Start the parse in the background and close — the widget takes it from here.
|
// Start the parse in the background and close — the widget takes it from here.
|
||||||
const handleParse = async () => {
|
const handleParse = async () => {
|
||||||
if (files.length === 0 || loading) return
|
if (files.length === 0 || loading || (renderContent && !uploadAvailable)) return
|
||||||
// Reading a booking runs on the server: offline there is nothing to send it to.
|
// Reading a booking runs on the server: offline there is nothing to send it to.
|
||||||
if (isEffectivelyOffline()) { setError(t('reservations.needsConnection')); return }
|
if (isEffectivelyOffline()) { setError(t('reservations.needsConnection')); return }
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
@@ -136,6 +173,27 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo
|
|||||||
|
|
||||||
if (!isOpen) return null
|
if (!isOpen) return null
|
||||||
|
|
||||||
|
const fileInput = (
|
||||||
|
<input
|
||||||
|
ref={fileInputRef}
|
||||||
|
type="file"
|
||||||
|
accept={acceptedExts.join(',')}
|
||||||
|
multiple
|
||||||
|
hidden
|
||||||
|
onChange={handleInputChange}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
if (renderContent) {
|
||||||
|
return renderContent({
|
||||||
|
tripId, files, fileInput, isDragOver, loading, error, available: uploadAvailable, readsPhotos,
|
||||||
|
pickFiles: () => fileInputRef.current?.click(),
|
||||||
|
removeFile: index => setFiles(current => current.filter((_, i) => i !== index)),
|
||||||
|
dragHandlers: { onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop },
|
||||||
|
handleClose, handleParse,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<div
|
<div
|
||||||
role="presentation"
|
role="presentation"
|
||||||
@@ -169,14 +227,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo
|
|||||||
{readsPhotos && <> {t('reservations.import.acceptedPhotos')}</>}
|
{readsPhotos && <> {t('reservations.import.acceptedPhotos')}</>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input
|
{fileInput}
|
||||||
ref={fileInputRef}
|
|
||||||
type="file"
|
|
||||||
accept={acceptedExts.join(',')}
|
|
||||||
multiple
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
onChange={handleInputChange}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -224,7 +275,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo
|
|||||||
{t('common.cancel')}
|
{t('common.cancel')}
|
||||||
</button>
|
</button>
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onClick={handleParse}
|
onClick={() => void handleParse()}
|
||||||
disabled={files.length === 0 || loading}
|
disabled={files.length === 0 || loading}
|
||||||
className={files.length > 0 && !loading ? 'bg-accent text-accent-text' : 'bg-surface-tertiary text-content-faint'}
|
className={files.length > 0 && !loading ? 'bg-accent text-accent-text' : 'bg-surface-tertiary text-content-faint'}
|
||||||
style={{ padding: '8px 16px', borderRadius: 10, border: 'none', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: files.length > 0 && !loading ? 'pointer' : 'default', fontFamily: 'inherit' }}
|
style={{ padding: '8px 16px', borderRadius: 10, border: 'none', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: files.length > 0 && !loading ? 'pointer' : 'default', fontFamily: 'inherit' }}
|
||||||
|
|||||||
@@ -5,11 +5,7 @@ import { http, HttpResponse } from 'msw';
|
|||||||
import { server } from '../../../tests/helpers/msw/server';
|
import { server } from '../../../tests/helpers/msw/server';
|
||||||
import { IcsSubscribeModal } from './IcsSubscribeModal';
|
import { IcsSubscribeModal } from './IcsSubscribeModal';
|
||||||
|
|
||||||
// The phone keeps the dialog's own markup, the desktop draws it in the shared
|
import MIcsSubscribeSheet from '../../mobile/screens/trip/sheets/MIcsSubscribeSheet';
|
||||||
// dialog frame. useIsPhone reads matchMedia, which the test setup always
|
|
||||||
// answers with false, so the phone is switched on by hand.
|
|
||||||
const phone = vi.hoisted(() => ({ value: false }));
|
|
||||||
vi.mock('../../mobile/useIsPhone', () => ({ useIsPhone: () => phone.value }));
|
|
||||||
|
|
||||||
const ENDPOINT = '/api/trips/9/feed';
|
const ENDPOINT = '/api/trips/9/feed';
|
||||||
const TOKEN_URL = `${ENDPOINT}/token`;
|
const TOKEN_URL = `${ENDPOINT}/token`;
|
||||||
@@ -31,17 +27,13 @@ function tokenHandlers(handler: (method: string) => Response | Promise<Response>
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEach(() => { phone.value = false; });
|
|
||||||
|
|
||||||
// Everything a user can do with the link works the same on both shells.
|
// Everything a user can do with the link works the same on both shells.
|
||||||
describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal on the %s', (_shell, isPhone) => {
|
describe.each([['phone', MIcsSubscribeSheet], ['desktop', IcsSubscribeModal]] as const)('IcsSubscribeModal on the %s', (_shell, SubscribeDialog) => {
|
||||||
beforeEach(() => { phone.value = isPhone; });
|
|
||||||
|
|
||||||
it('FE-PLANNER-ICS-001: shows the loading state until the token read resolves', async () => {
|
it('FE-PLANNER-ICS-001: shows the loading state until the token read resolves', async () => {
|
||||||
let release: (() => void) | null = null;
|
let release: (() => void) | null = null;
|
||||||
const gate = new Promise<void>(res => { release = res; });
|
const gate = new Promise<void>(res => { release = res; });
|
||||||
server.use(http.get(TOKEN_URL, async () => { await gate; return HttpResponse.json({ feed_url: null }); }));
|
server.use(http.get(TOKEN_URL, async () => { await gate; return HttpResponse.json({ feed_url: null }); }));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
expect(screen.getByText('Loading...')).toBeInTheDocument();
|
expect(screen.getByText('Loading...')).toBeInTheDocument();
|
||||||
release!();
|
release!();
|
||||||
await waitFor(() => expect(screen.queryByText('Loading...')).not.toBeInTheDocument());
|
await waitFor(() => expect(screen.queryByText('Loading...')).not.toBeInTheDocument());
|
||||||
@@ -49,7 +41,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-002: renders title and description in the header', async () => {
|
it('FE-PLANNER-ICS-002: renders title and description in the header', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
expect(screen.getByText('Subscribe to this trip')).toBeInTheDocument();
|
expect(screen.getByText('Subscribe to this trip')).toBeInTheDocument();
|
||||||
expect(screen.getByText('Keep the itinerary in your own calendar.')).toBeInTheDocument();
|
expect(screen.getByText('Keep the itinerary in your own calendar.')).toBeInTheDocument();
|
||||||
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
||||||
@@ -57,7 +49,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-003: with no token yet it offers the enable button, no links', async () => {
|
it('FE-PLANNER-ICS-003: with no token yet it offers the enable button, no links', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
expect(await screen.findByRole('button', { name: /Enable calendar subscription/i })).toBeInTheDocument();
|
expect(await screen.findByRole('button', { name: /Enable calendar subscription/i })).toBeInTheDocument();
|
||||||
expect(screen.getByText(/Creates a secret link/i)).toBeInTheDocument();
|
expect(screen.getByText(/Creates a secret link/i)).toBeInTheDocument();
|
||||||
expect(screen.queryByRole('link', { name: /Add to Google Calendar/i })).not.toBeInTheDocument();
|
expect(screen.queryByRole('link', { name: /Add to Google Calendar/i })).not.toBeInTheDocument();
|
||||||
@@ -69,7 +61,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
http.get(TOKEN_URL, () => { seen.push('GET'); return HttpResponse.json({ feed_url: null }); }),
|
http.get(TOKEN_URL, () => { seen.push('GET'); return HttpResponse.json({ feed_url: null }); }),
|
||||||
http.post(TOKEN_URL, () => { seen.push('POST'); return HttpResponse.json({ feed_url: 'https://trek.example/api/trips/9/feed/tok.ics' }); }),
|
http.post(TOKEN_URL, () => { seen.push('POST'); return HttpResponse.json({ feed_url: 'https://trek.example/api/trips/9/feed/tok.ics' }); }),
|
||||||
);
|
);
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
fireEvent.click(await screen.findByRole('button', { name: /Enable calendar subscription/i }));
|
fireEvent.click(await screen.findByRole('button', { name: /Enable calendar subscription/i }));
|
||||||
expect(await screen.findByRole('link', { name: /Add to Google Calendar/i })).toBeInTheDocument();
|
expect(await screen.findByRole('link', { name: /Add to Google Calendar/i })).toBeInTheDocument();
|
||||||
expect(seen).toEqual(['GET', 'POST']);
|
expect(seen).toEqual(['GET', 'POST']);
|
||||||
@@ -79,7 +71,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-005: an absolute feed_url is handed to the links as https and webcal', async () => {
|
it('FE-PLANNER-ICS-005: an absolute feed_url is handed to the links as https and webcal', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/tok.ics' })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/tok.ics' })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
expect(await screen.findByText('https://trek.example/feed/tok.ics')).toBeInTheDocument();
|
expect(await screen.findByText('https://trek.example/feed/tok.ics')).toBeInTheDocument();
|
||||||
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
||||||
.toHaveAttribute('href', 'webcal://trek.example/feed/tok.ics');
|
.toHaveAttribute('href', 'webcal://trek.example/feed/tok.ics');
|
||||||
@@ -87,7 +79,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-006: a host-relative feed_url is resolved against the current origin', async () => {
|
it('FE-PLANNER-ICS-006: a host-relative feed_url is resolved against the current origin', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: '/api/trips/9/feed/tok.ics' })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: '/api/trips/9/feed/tok.ics' })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
const absolute = `${window.location.origin}/api/trips/9/feed/tok.ics`;
|
const absolute = `${window.location.origin}/api/trips/9/feed/tok.ics`;
|
||||||
expect(await screen.findByText(absolute)).toBeInTheDocument();
|
expect(await screen.findByText(absolute)).toBeInTheDocument();
|
||||||
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
||||||
@@ -96,7 +88,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-012: a feed_url with neither scheme nor leading slash is used verbatim', async () => {
|
it('FE-PLANNER-ICS-012: a feed_url with neither scheme nor leading slash is used verbatim', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'trips/9/feed/tok.ics' })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'trips/9/feed/tok.ics' })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
// Nothing to absolutize against, so the raw value reaches the copy rows and
|
// Nothing to absolutize against, so the raw value reaches the copy rows and
|
||||||
// the webcal handoff stays schemeless rather than being mangled.
|
// the webcal handoff stays schemeless rather than being mangled.
|
||||||
expect(await screen.findAllByText('trips/9/feed/tok.ics')).toHaveLength(2);
|
expect(await screen.findAllByText('trips/9/feed/tok.ics')).toHaveLength(2);
|
||||||
@@ -110,7 +102,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/old.ics' })),
|
http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/old.ics' })),
|
||||||
http.put(TOKEN_URL, () => { method = 'PUT'; return HttpResponse.json({ feed_url: 'https://trek.example/feed/new.ics' }); }),
|
http.put(TOKEN_URL, () => { method = 'PUT'; return HttpResponse.json({ feed_url: 'https://trek.example/feed/new.ics' }); }),
|
||||||
);
|
);
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
fireEvent.click(await screen.findByRole('button', { name: /Regenerate/i }));
|
fireEvent.click(await screen.findByRole('button', { name: /Regenerate/i }));
|
||||||
expect(await screen.findByText('https://trek.example/feed/new.ics')).toBeInTheDocument();
|
expect(await screen.findByText('https://trek.example/feed/new.ics')).toBeInTheDocument();
|
||||||
expect(method).toBe('PUT');
|
expect(method).toBe('PUT');
|
||||||
@@ -122,7 +114,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/tok.ics' })),
|
http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/tok.ics' })),
|
||||||
http.delete(TOKEN_URL, () => { method = 'DELETE'; return HttpResponse.json({ feed_url: null }); }),
|
http.delete(TOKEN_URL, () => { method = 'DELETE'; return HttpResponse.json({ feed_url: null }); }),
|
||||||
);
|
);
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
fireEvent.click(await screen.findByRole('button', { name: /Turn off/i }));
|
fireEvent.click(await screen.findByRole('button', { name: /Turn off/i }));
|
||||||
expect(await screen.findByRole('button', { name: /Enable calendar subscription/i })).toBeInTheDocument();
|
expect(await screen.findByRole('button', { name: /Enable calendar subscription/i })).toBeInTheDocument();
|
||||||
expect(method).toBe('DELETE');
|
expect(method).toBe('DELETE');
|
||||||
@@ -130,7 +122,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-009: a failing token read still leaves the dialog usable', async () => {
|
it('FE-PLANNER-ICS-009: a failing token read still leaves the dialog usable', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.error()));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.error()));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
// The catch swallows the error, loading clears, and the enable path is offered.
|
// The catch swallows the error, loading clears, and the enable path is offered.
|
||||||
expect(await screen.findByRole('button', { name: /Enable calendar subscription/i })).toBeInTheDocument();
|
expect(await screen.findByRole('button', { name: /Enable calendar subscription/i })).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
@@ -141,7 +133,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
? HttpResponse.json({ feed_url: 'https://trek.example/feed/keep.ics' })
|
? HttpResponse.json({ feed_url: 'https://trek.example/feed/keep.ics' })
|
||||||
: new HttpResponse(null, { status: 500 }))),
|
: new HttpResponse(null, { status: 500 }))),
|
||||||
);
|
);
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
const regenerate = await screen.findByRole('button', { name: /Regenerate/i });
|
const regenerate = await screen.findByRole('button', { name: /Regenerate/i });
|
||||||
fireEvent.click(regenerate);
|
fireEvent.click(regenerate);
|
||||||
await waitFor(() => expect(regenerate).not.toBeDisabled());
|
await waitFor(() => expect(regenerate).not.toBeDisabled());
|
||||||
@@ -150,7 +142,7 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-017: the day overview switch is on, and off adds days=0 to every link (#2602)', async () => {
|
it('FE-PLANNER-ICS-017: the day overview switch is on, and off adds days=0 to every link (#2602)', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/tok.ics' })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/tok.ics' })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
const toggle = await screen.findByRole('button', { name: 'Day overview events' });
|
const toggle = await screen.findByRole('button', { name: 'Day overview events' });
|
||||||
expect(toggle).toHaveAttribute('aria-pressed', 'true');
|
expect(toggle).toHaveAttribute('aria-pressed', 'true');
|
||||||
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
||||||
@@ -170,27 +162,23 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-018: the day overview switch only shows once there is a link to change', async () => {
|
it('FE-PLANNER-ICS-018: the day overview switch only shows once there is a link to change', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<SubscribeDialog {...defaultProps} />);
|
||||||
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
||||||
expect(screen.queryByRole('button', { name: 'Day overview events' })).not.toBeInTheDocument();
|
expect(screen.queryByRole('button', { name: 'Day overview events' })).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('IcsSubscribeModal on the phone', () => {
|
describe('IcsSubscribeModal on the phone', () => {
|
||||||
beforeEach(() => { phone.value = true; });
|
|
||||||
|
|
||||||
it('FE-PLANNER-ICS-011: the close button and a backdrop click both call onClose, an inner click does not', async () => {
|
it('FE-PLANNER-ICS-011: the close button and a backdrop click both call onClose, an inner click does not', async () => {
|
||||||
const onClose = vi.fn();
|
const onClose = vi.fn();
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} onClose={onClose} />);
|
render(<MIcsSubscribeSheet {...defaultProps} onClose={onClose} />);
|
||||||
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
||||||
|
|
||||||
const closeBtn = screen.getByText('Subscribe to this trip').closest('div')!.parentElement!
|
fireEvent.click(screen.getByRole('button', { name: 'Close' }));
|
||||||
.querySelector('button') as HTMLButtonElement;
|
|
||||||
fireEvent.click(closeBtn);
|
|
||||||
expect(onClose).toHaveBeenCalledTimes(1);
|
expect(onClose).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
const backdrop = document.querySelector('[style*="position: fixed"]') as HTMLElement;
|
const backdrop = document.querySelector('[data-m-scrim]')!.parentElement!;
|
||||||
fireEvent.click(backdrop);
|
fireEvent.click(backdrop);
|
||||||
expect(onClose).toHaveBeenCalledTimes(2);
|
expect(onClose).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
@@ -200,10 +188,9 @@ describe('IcsSubscribeModal on the phone', () => {
|
|||||||
|
|
||||||
it('FE-PLANNER-ICS-013: the phone keeps its own sheet, not the desktop dialog frame', async () => {
|
it('FE-PLANNER-ICS-013: the phone keeps its own sheet, not the desktop dialog frame', async () => {
|
||||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
||||||
render(<IcsSubscribeModal {...defaultProps} />);
|
render(<MIcsSubscribeSheet {...defaultProps} />);
|
||||||
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
||||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
expect(screen.getByRole('dialog', { name: defaultProps.title })).toHaveAttribute('data-m-sheet', 'open');
|
||||||
expect(document.querySelector('[style*="z-index: 9999"]')).not.toBeNull();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import { useState, useEffect, useCallback, useId, type ReactNode } from 'react'
|
import { useState, useEffect, useId, type ReactNode } from 'react'
|
||||||
import { createPortal } from 'react-dom'
|
import { RefreshCw, Calendar, Power } from 'lucide-react'
|
||||||
import { X, RefreshCw, Calendar, Power } from 'lucide-react'
|
|
||||||
import { SubscribeLinks } from './SubscribeLinks'
|
import { SubscribeLinks } from './SubscribeLinks'
|
||||||
import ToggleSwitch from '../Settings/ToggleSwitch'
|
import ToggleSwitch from '../Settings/ToggleSwitch'
|
||||||
import { useIsPhone } from '../../mobile/useIsPhone'
|
|
||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||||
|
|
||||||
interface IcsSubscribeModalProps {
|
export interface IcsSubscribeModalProps {
|
||||||
/** Token endpoint base, e.g. `/api/trips/123/feed` or `/api/feed/user`. */
|
/** Token endpoint base, e.g. `/api/trips/123/feed` or `/api/feed/user`. */
|
||||||
endpoint: string
|
endpoint: string
|
||||||
title: string
|
title: string
|
||||||
@@ -34,7 +32,7 @@ function withDayEvents(url: string, dayEvents: boolean): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The switch for those summaries, above the links it changes, on both shells. */
|
/** The switch for those summaries, above the links it changes, on both shells. */
|
||||||
function DayEventsSwitch({ on, onToggle }: { on: boolean; onToggle: () => void }) {
|
export function DayEventsSwitch({ on, onToggle }: { on: boolean; onToggle: () => void }) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const hintId = useId()
|
const hintId = useId()
|
||||||
return (
|
return (
|
||||||
@@ -50,42 +48,31 @@ function DayEventsSwitch({ on, onToggle }: { on: boolean; onToggle: () => void }
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Opening reads the token. Creating or changing it always takes an explicit action. */
|
||||||
* Shared subscribe dialog for the per-trip and all-trips ICS feeds. Opening it
|
export function useIcsSubscription(endpoint: string) {
|
||||||
* only *reads* the current token — it never mints one silently. The user
|
|
||||||
* explicitly enables the public link, and can rotate or fully turn it off.
|
|
||||||
*
|
|
||||||
* The phone keeps its own markup; the desktop draws the same steps in the
|
|
||||||
* planner's dialog frame, with the link's controls in the bar at the foot.
|
|
||||||
*/
|
|
||||||
export function IcsSubscribeModal({ endpoint, title, description, onClose }: IcsSubscribeModalProps) {
|
|
||||||
const tokenUrl = `${endpoint}/token`
|
const tokenUrl = `${endpoint}/token`
|
||||||
const [feedUrl, setFeedUrl] = useState<string | null>(null)
|
const [feedUrl, setFeedUrl] = useState<string | null>(null)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loadedTokenUrl, setLoadedTokenUrl] = useState<string | null>(null)
|
||||||
const [busy, setBusy] = useState(false)
|
const [busy, setBusy] = useState(false)
|
||||||
const [dayEvents, setDayEvents] = useState(true)
|
const [dayEvents, setDayEvents] = useState(true)
|
||||||
const toggleDayEvents = () => setDayEvents(on => !on)
|
const toggleDayEvents = () => setDayEvents(on => !on)
|
||||||
const isPhone = useIsPhone()
|
|
||||||
const { t } = useTranslation()
|
|
||||||
const titleId = useId()
|
|
||||||
|
|
||||||
const httpsUrl = feedUrl ? withDayEvents(absolutize(feedUrl), dayEvents) : ''
|
const httpsUrl = feedUrl ? withDayEvents(absolutize(feedUrl), dayEvents) : ''
|
||||||
const webcalUrl = httpsUrl ? httpsUrl.replace(/^https?:\/\//, 'webcal://') : ''
|
const webcalUrl = httpsUrl ? httpsUrl.replace(/^https?:\/\//, 'webcal://') : ''
|
||||||
|
|
||||||
const load = useCallback(async () => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
let active = true
|
||||||
try {
|
void fetch(tokenUrl, { credentials: 'include' })
|
||||||
const res = await fetch(tokenUrl, { credentials: 'include' })
|
.then(async res => res.ok ? (await res.json() as { feed_url: string | null }).feed_url : null)
|
||||||
if (res.ok) {
|
.catch(() => null)
|
||||||
const data = await res.json() as { feed_url: string | null }
|
.then(url => {
|
||||||
setFeedUrl(data.feed_url)
|
if (!active) return
|
||||||
}
|
setFeedUrl(url)
|
||||||
} catch { /* ignore */ }
|
setLoadedTokenUrl(tokenUrl)
|
||||||
setLoading(false)
|
})
|
||||||
|
return () => { active = false }
|
||||||
}, [tokenUrl])
|
}, [tokenUrl])
|
||||||
|
|
||||||
useEffect(() => { load() }, [load])
|
|
||||||
|
|
||||||
const mutate = async (method: 'POST' | 'PUT' | 'DELETE') => {
|
const mutate = async (method: 'POST' | 'PUT' | 'DELETE') => {
|
||||||
setBusy(true)
|
setBusy(true)
|
||||||
try {
|
try {
|
||||||
@@ -98,143 +85,27 @@ export function IcsSubscribeModal({ endpoint, title, description, onClose }: Ics
|
|||||||
setBusy(false)
|
setBusy(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPhone) {
|
return { loading: loadedTokenUrl !== tokenUrl, busy, feedUrl, httpsUrl, webcalUrl, mutate, dayEvents, toggleDayEvents }
|
||||||
return (
|
}
|
||||||
<DesktopSubscribeDialog
|
|
||||||
titleId={titleId}
|
|
||||||
title={title}
|
|
||||||
description={description}
|
|
||||||
onClose={onClose}
|
|
||||||
loading={loading}
|
|
||||||
busy={busy}
|
|
||||||
feedUrl={feedUrl}
|
|
||||||
httpsUrl={httpsUrl}
|
|
||||||
webcalUrl={webcalUrl}
|
|
||||||
mutate={mutate}
|
|
||||||
dayEvents={dayEvents}
|
|
||||||
onToggleDayEvents={toggleDayEvents}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return createPortal(
|
export function IcsSubscribeModal({ endpoint, title, description, onClose }: IcsSubscribeModalProps) {
|
||||||
<div
|
const titleId = useId()
|
||||||
role="presentation"
|
const { loading, busy, feedUrl, httpsUrl, webcalUrl, mutate, dayEvents, toggleDayEvents } = useIcsSubscription(endpoint)
|
||||||
style={{
|
return (
|
||||||
position: 'fixed', inset: 0, zIndex: 9999,
|
<DesktopSubscribeDialog
|
||||||
background: 'rgba(0,0,0,0.5)',
|
titleId={titleId}
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
title={title}
|
||||||
padding: '16px',
|
description={description}
|
||||||
}}
|
onClose={onClose}
|
||||||
onClick={e => { if (e.target === e.currentTarget) onClose() }}
|
loading={loading}
|
||||||
>
|
busy={busy}
|
||||||
<div style={{
|
feedUrl={feedUrl}
|
||||||
background: 'var(--bg-card, white)',
|
httpsUrl={httpsUrl}
|
||||||
borderRadius: 14,
|
webcalUrl={webcalUrl}
|
||||||
padding: '22px 24px',
|
mutate={mutate}
|
||||||
width: '100%',
|
dayEvents={dayEvents}
|
||||||
maxWidth: 420,
|
onToggleDayEvents={toggleDayEvents}
|
||||||
boxShadow: '0 16px 48px rgba(0,0,0,0.22)',
|
/>
|
||||||
border: '1px solid var(--border-faint)',
|
|
||||||
color: 'var(--text-primary)',
|
|
||||||
fontFamily: 'inherit',
|
|
||||||
position: 'relative',
|
|
||||||
}}>
|
|
||||||
{/* Header */}
|
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 14 }}>
|
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
||||||
<Calendar size={16} strokeWidth={2} style={{ color: 'var(--accent, #6366f1)' }} />
|
|
||||||
<span style={{ fontWeight: 600, fontSize: 14 }}>{title}</span>
|
|
||||||
</div>
|
|
||||||
<button type="button"
|
|
||||||
onClick={onClose}
|
|
||||||
aria-label={t('common.close')}
|
|
||||||
style={{
|
|
||||||
background: 'none', border: 'none', cursor: 'pointer', padding: 4,
|
|
||||||
color: 'var(--text-muted)', borderRadius: 6, display: 'flex',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<X size={15} strokeWidth={2} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p style={{ fontSize: 12, color: 'var(--text-muted)', marginBottom: 16, lineHeight: 1.5 }}>
|
|
||||||
{description}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{loading ? (
|
|
||||||
<div style={{ textAlign: 'center', padding: '16px 0', color: 'var(--text-muted)', fontSize: 12 }}>
|
|
||||||
{t('common.loading')}
|
|
||||||
</div>
|
|
||||||
) : !feedUrl ? (
|
|
||||||
<>
|
|
||||||
<button type="button"
|
|
||||||
onClick={() => mutate('POST')}
|
|
||||||
disabled={busy}
|
|
||||||
style={{
|
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
|
||||||
width: '100%', padding: '9px 14px', borderRadius: 9, border: 'none',
|
|
||||||
background: 'var(--accent, #6366f1)', color: 'var(--accent-text, #fff)',
|
|
||||||
fontSize: 12, fontWeight: 600, fontFamily: 'inherit',
|
|
||||||
cursor: busy ? 'default' : 'pointer', opacity: busy ? 0.6 : 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Calendar size={14} strokeWidth={2} />
|
|
||||||
{t('dashboard.ics.enable')}
|
|
||||||
</button>
|
|
||||||
<p style={{ fontSize: 10, color: 'var(--text-muted)', marginTop: 8, lineHeight: 1.4 }}>
|
|
||||||
{t('dashboard.ics.enableHint')}
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div style={{ marginBottom: 16 }}>
|
|
||||||
<DayEventsSwitch on={dayEvents} onToggle={toggleDayEvents} />
|
|
||||||
</div>
|
|
||||||
<SubscribeLinks httpsUrl={httpsUrl} webcalUrl={webcalUrl} />
|
|
||||||
|
|
||||||
<div style={{ marginTop: 16, paddingTop: 12, borderTop: '1px solid var(--border-faint)', display: 'flex', gap: 8 }}>
|
|
||||||
<button type="button"
|
|
||||||
onClick={() => mutate('PUT')}
|
|
||||||
disabled={busy}
|
|
||||||
style={{
|
|
||||||
display: 'flex', alignItems: 'center', gap: 6,
|
|
||||||
background: 'none', border: '1px solid var(--border-primary)',
|
|
||||||
borderRadius: 7, padding: '5px 10px',
|
|
||||||
fontSize: 11, color: 'var(--text-muted)',
|
|
||||||
cursor: busy ? 'default' : 'pointer',
|
|
||||||
fontFamily: 'inherit', opacity: busy ? 0.6 : 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<RefreshCw size={11} strokeWidth={2} style={{ animation: busy ? 'spin 0.8s linear infinite' : 'none' }} />
|
|
||||||
{t('dashboard.ics.regenerate')}
|
|
||||||
</button>
|
|
||||||
<button type="button"
|
|
||||||
onClick={() => mutate('DELETE')}
|
|
||||||
disabled={busy}
|
|
||||||
style={{
|
|
||||||
display: 'flex', alignItems: 'center', gap: 6,
|
|
||||||
background: 'none', border: '1px solid var(--border-primary)',
|
|
||||||
borderRadius: 7, padding: '5px 10px',
|
|
||||||
fontSize: 11, color: 'var(--danger, #dc2626)',
|
|
||||||
cursor: busy ? 'default' : 'pointer',
|
|
||||||
fontFamily: 'inherit', opacity: busy ? 0.6 : 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Power size={11} strokeWidth={2} />
|
|
||||||
{t('dashboard.ics.turnOff')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p style={{ fontSize: 10, color: 'var(--text-muted)', marginTop: 6, lineHeight: 1.4 }}>
|
|
||||||
{t('dashboard.ics.manageHint')}
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>{`@keyframes spin { to { transform: rotate(360deg); } }`}</style>
|
|
||||||
</div>,
|
|
||||||
document.body
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +153,7 @@ function DesktopSubscribeDialog({ titleId, title, description, onClose, loading,
|
|||||||
footer = (
|
footer = (
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<FooterSpacer />
|
<FooterSpacer />
|
||||||
<DialogButton variant="primary" onClick={() => mutate('POST')} disabled={busy} icon={<Calendar size={14} strokeWidth={2} />}>
|
<DialogButton variant="primary" onClick={() => void mutate('POST')} disabled={busy} icon={<Calendar size={14} strokeWidth={2} />}>
|
||||||
{t('dashboard.ics.enable')}
|
{t('dashboard.ics.enable')}
|
||||||
</DialogButton>
|
</DialogButton>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
@@ -299,11 +170,11 @@ function DesktopSubscribeDialog({ titleId, title, description, onClose, loading,
|
|||||||
)
|
)
|
||||||
footer = (
|
footer = (
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<DialogButton onClick={() => mutate('PUT')} disabled={busy} icon={<RefreshCw size={14} strokeWidth={2} className={busy ? 'animate-spin' : ''} />}>
|
<DialogButton onClick={() => void mutate('PUT')} disabled={busy} icon={<RefreshCw size={14} strokeWidth={2} className={busy ? 'animate-spin' : ''} />}>
|
||||||
{t('dashboard.ics.regenerate')}
|
{t('dashboard.ics.regenerate')}
|
||||||
</DialogButton>
|
</DialogButton>
|
||||||
<FooterSpacer />
|
<FooterSpacer />
|
||||||
<button type="button" onClick={() => mutate('DELETE')} disabled={busy} className={TURN_OFF_BTN} style={fs(13, 'body')}>
|
<button type="button" onClick={() => void mutate('DELETE')} disabled={busy} className={TURN_OFF_BTN} style={fs(13, 'body')}>
|
||||||
<Power size={14} strokeWidth={2} />
|
<Power size={14} strokeWidth={2} />
|
||||||
{t('dashboard.ics.turnOff')}
|
{t('dashboard.ics.turnOff')}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -86,6 +86,20 @@ describe('PlaceDetailsColumn', () => {
|
|||||||
expect(placeEnrichment).not.toHaveBeenCalled()
|
expect(placeEnrichment).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('lets a mobile user upload a picture without opening an empty details group', () => {
|
||||||
|
renderColumn({
|
||||||
|
selection: null,
|
||||||
|
variant: 'mobile',
|
||||||
|
image: {
|
||||||
|
chosen: { kind: 'none' },
|
||||||
|
own: { currentUrl: null, attached: [], pendingPreview: null, canUpload: true, onUpload: vi.fn(), onPickAttached: vi.fn(), onRemove: vi.fn() },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(screen.getByRole('button', { name: 'places.uploadImage' })).toHaveTextContent('places.uploadImage')
|
||||||
|
expect(screen.queryByText('places.details.empty')).not.toBeInTheDocument()
|
||||||
|
expect(placeEnrichment).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
it('FE-PDC-002: shows a loading state, then the result', async () => {
|
it('FE-PDC-002: shows a loading state, then the result', async () => {
|
||||||
let settle: (v: MapsPlaceEnrichmentResult) => void = () => {}
|
let settle: (v: MapsPlaceEnrichmentResult) => void = () => {}
|
||||||
placeEnrichment.mockReturnValue(new Promise<MapsPlaceEnrichmentResult>((r) => { settle = r }))
|
placeEnrichment.mockReturnValue(new Promise<MapsPlaceEnrichmentResult>((r) => { settle = r }))
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ interface PlaceDetailsColumnProps {
|
|||||||
* small eyebrows. The default is the phone sheet's look: a card in the mobile
|
* small eyebrows. The default is the phone sheet's look: a card in the mobile
|
||||||
* tokens with the same one-line hints.
|
* tokens with the same one-line hints.
|
||||||
*/
|
*/
|
||||||
variant?: 'sheet' | 'dialog'
|
variant?: 'sheet' | 'dialog' | 'mobile'
|
||||||
/** False on an instance with no Google key, which is most of them. */
|
/** False on an instance with no Google key, which is most of them. */
|
||||||
t: TranslationFn
|
t: TranslationFn
|
||||||
}
|
}
|
||||||
@@ -91,8 +91,7 @@ function SheetHint({ icon, children }: { icon: React.ReactNode; children: React.
|
|||||||
*/
|
*/
|
||||||
function Overline({ children }: { children: React.ReactNode }): React.ReactElement {
|
function Overline({ children }: { children: React.ReactNode }): React.ReactElement {
|
||||||
return (
|
return (
|
||||||
// The phone form's eyebrow (mobile Eyebrow), so these labels match Name, Notes and the rest below.
|
<p className="text-control font-medium text-m-ink">{children}</p>
|
||||||
<p className="font-geist text-[length:calc(10px*var(--fs-scale-caption,1))] font-bold uppercase tracking-[.09em] text-m-faint">{children}</p>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +132,7 @@ export default function PlaceDetailsColumn({
|
|||||||
t,
|
t,
|
||||||
}: PlaceDetailsColumnProps): React.ReactElement {
|
}: PlaceDetailsColumnProps): React.ReactElement {
|
||||||
const dialog = variant === 'dialog'
|
const dialog = variant === 'dialog'
|
||||||
|
const mobile = variant === 'mobile'
|
||||||
const adoptBlockedId = useId()
|
const adoptBlockedId = useId()
|
||||||
const [data, setData] = useState<MapsPlaceEnrichmentResult | null>(null)
|
const [data, setData] = useState<MapsPlaceEnrichmentResult | null>(null)
|
||||||
const [state, setState] = useState<LoadState>('idle')
|
const [state, setState] = useState<LoadState>('idle')
|
||||||
@@ -233,12 +233,27 @@ export default function PlaceDetailsColumn({
|
|||||||
!data?.hours &&
|
!data?.hours &&
|
||||||
!data?.rating
|
!data?.rating
|
||||||
|
|
||||||
|
const pictures = (
|
||||||
|
<PictureBlock
|
||||||
|
photos={state === 'ready' && !data?.disabled ? (data?.photos ?? []) : []}
|
||||||
|
chosen={image?.chosen ?? chosenImage(selectedImageUrl, null, null)}
|
||||||
|
onPickImage={onPickImage}
|
||||||
|
own={image?.own}
|
||||||
|
dialog={dialog}
|
||||||
|
mobile={mobile}
|
||||||
|
t={t}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
if (mobile && !selection) return pictures
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// 320px, not 288: the picture grid was doing (288 - 24 - 12) / 3 = 84px
|
// 320px, not 288: the picture grid was doing (288 - 24 - 12) / 3 = 84px
|
||||||
// tiles, which is too small to tell a facade from a foyer. The column is
|
// tiles, which is too small to tell a facade from a foyer. The column is
|
||||||
// stretched to the form's height by the row it sits in, so the extra room
|
// stretched to the form's height by the row it sits in, so the extra room
|
||||||
// costs nothing that was being used.
|
// costs nothing that was being used.
|
||||||
<aside className={dialog ? `${SIDE_COLUMN} ${fluid ? '' : 'sm:w-80'}` : `w-full ${fluid ? '' : 'sm:w-80'} shrink-0 flex flex-col self-stretch`}>
|
<aside className={dialog ? `${SIDE_COLUMN} ${fluid ? '' : 'sm:w-80'}` : `w-full ${fluid ? '' : 'sm:w-80'} shrink-0 flex flex-col self-stretch`}>
|
||||||
|
{mobile && pictures}
|
||||||
{dialog ? (
|
{dialog ? (
|
||||||
<ColumnHead icon={<Landmark size={13} strokeWidth={2.2} />}>{t('places.details.title')}</ColumnHead>
|
<ColumnHead icon={<Landmark size={13} strokeWidth={2.2} />}>{t('places.details.title')}</ColumnHead>
|
||||||
) : (
|
) : (
|
||||||
@@ -247,11 +262,12 @@ export default function PlaceDetailsColumn({
|
|||||||
aria-expanded={open}
|
aria-expanded={open}
|
||||||
aria-controls={bodyId}
|
aria-controls={bodyId}
|
||||||
onClick={() => setOpen(o => !o)}
|
onClick={() => setOpen(o => !o)}
|
||||||
// A badge over the column's blocks: what they are, and the fold.
|
className={mobile
|
||||||
className="flex h-[36px] w-full shrink-0 items-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] pe-3 ps-3.5 text-start"
|
? 'mt-3 flex min-h-11 w-full shrink-0 items-center gap-2 rounded-xl border border-m-rowbr bg-m-sheetop px-3 text-start'
|
||||||
|
: 'flex h-[36px] w-full shrink-0 items-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] pe-3 ps-3.5 text-start'}
|
||||||
>
|
>
|
||||||
<Landmark size={13} strokeWidth={2.2} className="flex-none text-m-muted" />
|
<Landmark size={13} strokeWidth={2.2} className="flex-none text-m-muted" />
|
||||||
<span className="min-w-0 flex-1 truncate font-geist text-caption font-semibold text-m-ink">{t('places.details.title')}</span>
|
<span className="min-w-0 flex-1 text-control font-medium text-m-ink">{t('places.details.title')}</span>
|
||||||
<ChevronDown
|
<ChevronDown
|
||||||
size={13}
|
size={13}
|
||||||
strokeWidth={2.2}
|
strokeWidth={2.2}
|
||||||
@@ -268,14 +284,7 @@ export default function PlaceDetailsColumn({
|
|||||||
<div className={dialog ? 'flex min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto px-3 pb-3' : `min-h-0 overflow-hidden ${open ? '' : 'invisible'}`}>
|
<div className={dialog ? 'flex min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto px-3 pb-3' : `min-h-0 overflow-hidden ${open ? '' : 'invisible'}`}>
|
||||||
<div className={dialog ? 'contents' : 'space-y-3 pt-3'}>
|
<div className={dialog ? 'contents' : 'space-y-3 pt-3'}>
|
||||||
{/* The place's picture first: its own ones are there whatever the sources answer. */}
|
{/* The place's picture first: its own ones are there whatever the sources answer. */}
|
||||||
<PictureBlock
|
{!mobile && pictures}
|
||||||
photos={state === 'ready' && !data?.disabled ? (data?.photos ?? []) : []}
|
|
||||||
chosen={image?.chosen ?? chosenImage(selectedImageUrl, null, null)}
|
|
||||||
onPickImage={onPickImage}
|
|
||||||
own={image?.own}
|
|
||||||
dialog={dialog}
|
|
||||||
t={t}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Nothing picked yet, which is a state rather than a fault: one quiet
|
{/* Nothing picked yet, which is a state rather than a fault: one quiet
|
||||||
line, in the dialog and on the phone alike, so the form's own fields
|
line, in the dialog and on the phone alike, so the form's own fields
|
||||||
@@ -348,6 +357,7 @@ function PictureBlock({
|
|||||||
onPickImage,
|
onPickImage,
|
||||||
own,
|
own,
|
||||||
dialog,
|
dialog,
|
||||||
|
mobile,
|
||||||
t,
|
t,
|
||||||
}: {
|
}: {
|
||||||
photos: PlacePhotoCandidate[]
|
photos: PlacePhotoCandidate[]
|
||||||
@@ -355,10 +365,11 @@ function PictureBlock({
|
|||||||
onPickImage: (url: string | null) => void
|
onPickImage: (url: string | null) => void
|
||||||
own?: PlaceImageOwn
|
own?: PlaceImageOwn
|
||||||
dialog: boolean
|
dialog: boolean
|
||||||
|
mobile: boolean
|
||||||
t: TranslationFn
|
t: TranslationFn
|
||||||
}): React.ReactElement | null {
|
}): React.ReactElement | null {
|
||||||
if (!offersPictures(photos, own)) return null
|
if (!offersPictures(photos, own)) return null
|
||||||
const picker = <PlaceImagePicker photos={photos} chosen={chosen} onPickUrl={onPickImage} own={own} dialog={dialog} t={t} />
|
const picker = <PlaceImagePicker photos={photos} chosen={chosen} onPickUrl={onPickImage} own={own} dialog={dialog} mobile={mobile} t={t} />
|
||||||
return (
|
return (
|
||||||
<Block label={t('places.details.pickImage')} dialog={dialog}>
|
<Block label={t('places.details.pickImage')} dialog={dialog}>
|
||||||
{dialog ? <div className={`${COLUMN_CARD} p-2`}>{picker}</div> : picker}
|
{dialog ? <div className={`${COLUMN_CARD} p-2`}>{picker}</div> : picker}
|
||||||
|
|||||||
@@ -66,13 +66,23 @@ export function PendingFiles({
|
|||||||
export function PlaceImageSection({
|
export function PlaceImageSection({
|
||||||
image,
|
image,
|
||||||
onPickUrl,
|
onPickUrl,
|
||||||
|
mobile = false,
|
||||||
t,
|
t,
|
||||||
}: {
|
}: {
|
||||||
image: { own: PlaceImageOwn; chosen: ChosenImage };
|
image: { own: PlaceImageOwn; chosen: ChosenImage };
|
||||||
onPickUrl: (url: string | null) => void;
|
onPickUrl: (url: string | null) => void;
|
||||||
|
mobile?: boolean;
|
||||||
t: TranslationFn;
|
t: TranslationFn;
|
||||||
}) {
|
}) {
|
||||||
if (!offersPictures([], image.own)) return null;
|
if (!offersPictures([], image.own)) return null;
|
||||||
|
if (mobile) {
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<h3 className="mb-2 text-control font-medium text-m-ink">{t('places.details.pickImage')}</h3>
|
||||||
|
<PlaceImagePicker photos={[]} chosen={image.chosen} onPickUrl={onPickUrl} own={image.own} mobile t={t} />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className={LABEL}>{t('places.details.pickImage')}</div>
|
<div className={LABEL}>{t('places.details.pickImage')}</div>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ interface PlaceImagePickerProps {
|
|||||||
own?: PlaceImageOwn;
|
own?: PlaceImageOwn;
|
||||||
/** On a white card, without native tooltips: hovering moves the credit line instead. */
|
/** On a white card, without native tooltips: hovering moves the credit line instead. */
|
||||||
dialog?: boolean;
|
dialog?: boolean;
|
||||||
|
mobile?: boolean;
|
||||||
t: TranslationFn;
|
t: TranslationFn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ export default function PlaceImagePicker({
|
|||||||
onPickUrl,
|
onPickUrl,
|
||||||
own,
|
own,
|
||||||
dialog = false,
|
dialog = false,
|
||||||
|
mobile = false,
|
||||||
t,
|
t,
|
||||||
}: PlaceImagePickerProps): React.ReactElement | null {
|
}: PlaceImagePickerProps): React.ReactElement | null {
|
||||||
const [hovered, setHovered] = useState<Credit>(null);
|
const [hovered, setHovered] = useState<Credit>(null);
|
||||||
@@ -76,55 +78,62 @@ export default function PlaceImagePicker({
|
|||||||
|
|
||||||
const shown = hovered ?? creditFor(chosen, photos, attached, own, t);
|
const shown = hovered ?? creditFor(chosen, photos, attached, own, t);
|
||||||
const removable = !!own && chosen.kind !== 'none';
|
const removable = !!own && chosen.kind !== 'none';
|
||||||
|
const upload = own?.canUpload && (
|
||||||
|
<UploadTile
|
||||||
|
own={own}
|
||||||
|
selected={chosen.kind === 'upload'}
|
||||||
|
dialog={dialog}
|
||||||
|
mobile={mobile}
|
||||||
|
onHover={(on) => setHovered(on ? { kind: 'own', label: t('places.image.own') } : null)}
|
||||||
|
t={t}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
const showUploadRow = mobile && !own?.pendingPreview;
|
||||||
|
const showTiles = Boolean(current || attached.length || photos.length || (upload && !showUploadRow));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="grid grid-cols-3 gap-1.5">
|
{showUploadRow && upload}
|
||||||
{own?.canUpload && (
|
{showTiles && (
|
||||||
<UploadTile
|
<div className={`grid grid-cols-3 gap-1.5 ${showUploadRow && upload ? 'mt-2' : ''}`}>
|
||||||
own={own}
|
{!showUploadRow && upload}
|
||||||
selected={chosen.kind === 'upload'}
|
{current && (
|
||||||
dialog={dialog}
|
<button
|
||||||
onHover={(on) => setHovered(on ? { kind: 'own', label: t('places.image.own') } : null)}
|
type="button"
|
||||||
t={t}
|
onClick={() => (chosen.kind === 'current' ? own?.onRemove() : onPickUrl(current))}
|
||||||
/>
|
aria-pressed={chosen.kind === 'current'}
|
||||||
)}
|
aria-label={t('places.image.current')}
|
||||||
{current && (
|
onMouseEnter={() => setHovered({ kind: 'own', label: t('places.image.current') })}
|
||||||
<button
|
onMouseLeave={() => setHovered(null)}
|
||||||
type="button"
|
className={`${TILE} ${ring(chosen.kind === 'current', dialog)}`}
|
||||||
onClick={() => (chosen.kind === 'current' ? own?.onRemove() : onPickUrl(current))}
|
>
|
||||||
aria-pressed={chosen.kind === 'current'}
|
<img src={current} alt="" className="h-full w-full object-cover" />
|
||||||
aria-label={t('places.image.current')}
|
{chosen.kind === 'current' && <Picked />}
|
||||||
onMouseEnter={() => setHovered({ kind: 'own', label: t('places.image.current') })}
|
</button>
|
||||||
onMouseLeave={() => setHovered(null)}
|
)}
|
||||||
className={`${TILE} ${ring(chosen.kind === 'current', dialog)}`}
|
{attached.map((file) => (
|
||||||
>
|
<AttachedTile
|
||||||
<img src={current} alt="" className="h-full w-full object-cover" />
|
key={file.id}
|
||||||
{chosen.kind === 'current' && <Picked />}
|
file={file}
|
||||||
</button>
|
selected={chosen.kind === 'attached' && chosen.fileId === file.id}
|
||||||
)}
|
onPick={() => own?.onPickAttached(file)}
|
||||||
{attached.map((file) => (
|
onHover={(on) => setHovered(on ? { kind: 'own', label: file.original_name } : null)}
|
||||||
<AttachedTile
|
dialog={dialog}
|
||||||
key={file.id}
|
/>
|
||||||
file={file}
|
))}
|
||||||
selected={chosen.kind === 'attached' && chosen.fileId === file.id}
|
{photos.map((photo) => (
|
||||||
onPick={() => own?.onPickAttached(file)}
|
<PhotoTile
|
||||||
onHover={(on) => setHovered(on ? { kind: 'own', label: file.original_name } : null)}
|
key={photo.key}
|
||||||
dialog={dialog}
|
photo={photo}
|
||||||
/>
|
selected={chosen.kind === 'url' && chosen.url === photo.url}
|
||||||
))}
|
onPick={onPickUrl}
|
||||||
{photos.map((photo) => (
|
onHover={(on) => setHovered(on ? { kind: 'photo', photo } : null)}
|
||||||
<PhotoTile
|
dialog={dialog}
|
||||||
key={photo.key}
|
t={t}
|
||||||
photo={photo}
|
/>
|
||||||
selected={chosen.kind === 'url' && chosen.url === photo.url}
|
))}
|
||||||
onPick={onPickUrl}
|
</div>
|
||||||
onHover={(on) => setHovered(on ? { kind: 'photo', photo } : null)}
|
)}
|
||||||
dialog={dialog}
|
|
||||||
t={t}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
{(shown || removable) && (
|
{(shown || removable) && (
|
||||||
<CreditLine shown={shown} onRemove={removable ? own?.onRemove : undefined} dialog={dialog} t={t} />
|
<CreditLine shown={shown} onRemove={removable ? own?.onRemove : undefined} dialog={dialog} t={t} />
|
||||||
)}
|
)}
|
||||||
@@ -137,12 +146,14 @@ function UploadTile({
|
|||||||
own,
|
own,
|
||||||
selected,
|
selected,
|
||||||
dialog,
|
dialog,
|
||||||
|
mobile,
|
||||||
onHover,
|
onHover,
|
||||||
t,
|
t,
|
||||||
}: {
|
}: {
|
||||||
own: PlaceImageOwn;
|
own: PlaceImageOwn;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
dialog: boolean;
|
dialog: boolean;
|
||||||
|
mobile: boolean;
|
||||||
onHover: (on: boolean) => void;
|
onHover: (on: boolean) => void;
|
||||||
t: TranslationFn;
|
t: TranslationFn;
|
||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
@@ -162,36 +173,53 @@ function UploadTile({
|
|||||||
const preview = own.pendingPreview;
|
const preview = own.pendingPreview;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Tooltip label={t('places.uploadImage')} placement="top">
|
{mobile && !preview ? (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => fileRef.current?.click()}
|
onClick={() => fileRef.current?.click()}
|
||||||
disabled={reading}
|
disabled={reading}
|
||||||
aria-pressed={selected}
|
aria-busy={reading}
|
||||||
aria-label={t('places.uploadImage')}
|
className="flex min-h-11 w-full items-center gap-2 rounded-xl border border-m-rowbr bg-m-sheetop px-3 py-2 text-start text-control font-medium text-m-ink disabled:opacity-60"
|
||||||
className={`${TILE} ${ring(selected, dialog)} ${preview ? '' : dialog ? 'border border-edge-faint bg-surface-secondary hover:bg-surface-tertiary' : 'border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]'}`}
|
|
||||||
onMouseEnter={() => onHover(!!preview)}
|
|
||||||
onMouseLeave={() => onHover(false)}
|
|
||||||
>
|
>
|
||||||
{preview ? (
|
{reading ? (
|
||||||
<>
|
<Loader2 size={17} className="shrink-0 animate-spin text-m-muted" aria-hidden />
|
||||||
<img src={preview} alt="" className="h-full w-full object-cover" />
|
|
||||||
{selected && <Picked />}
|
|
||||||
</>
|
|
||||||
) : (
|
) : (
|
||||||
// Icon only: the tooltip and the button's name say what it does.
|
<ImagePlus size={17} className="shrink-0 text-m-muted" aria-hidden />
|
||||||
<span className="flex h-full w-full items-center justify-center">
|
|
||||||
<span className="grid h-11 w-11 place-items-center rounded-full bg-surface-card text-content-muted shadow-sm transition-transform duration-150 group-hover:scale-105 group-hover:text-content">
|
|
||||||
{reading ? (
|
|
||||||
<Loader2 className="h-5 w-5 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<ImagePlus className="h-5 w-5" strokeWidth={1.9} />
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
|
{t('places.uploadImage')}
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
) : (
|
||||||
|
<Tooltip label={t('places.uploadImage')} placement="top">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => fileRef.current?.click()}
|
||||||
|
disabled={reading}
|
||||||
|
aria-pressed={selected}
|
||||||
|
aria-label={t('places.uploadImage')}
|
||||||
|
className={`${TILE} ${ring(selected, dialog)} ${preview ? '' : dialog ? 'border border-edge-faint bg-surface-secondary hover:bg-surface-tertiary' : 'border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]'}`}
|
||||||
|
onMouseEnter={() => onHover(!!preview)}
|
||||||
|
onMouseLeave={() => onHover(false)}
|
||||||
|
>
|
||||||
|
{preview ? (
|
||||||
|
<>
|
||||||
|
<img src={preview} alt="" className="h-full w-full object-cover" />
|
||||||
|
{selected && <Picked />}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
// Icon only: the tooltip and the button's name say what it does.
|
||||||
|
<span className="flex h-full w-full items-center justify-center">
|
||||||
|
<span className="grid h-11 w-11 place-items-center rounded-full bg-surface-card text-content-muted shadow-sm transition-transform duration-150 group-hover:scale-105 group-hover:text-content">
|
||||||
|
{reading ? (
|
||||||
|
<Loader2 className="h-5 w-5 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<ImagePlus className="h-5 w-5" strokeWidth={1.9} />
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
<input ref={fileRef} type="file" accept="image/*,.heic,.heif" className="hidden" onChange={(e) => void pick(e)} />
|
<input ref={fileRef} type="file" accept="image/*,.heic,.heif" className="hidden" onChange={(e) => void pick(e)} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ interface SubscribeLinksProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared presentation for calendar subscription URLs. Renders one-click
|
* The provider links and clipboard behavior shared by both subscription dialogs.
|
||||||
* subscribe actions (Google deep link + webcal handoff) plus a copy fallback.
|
|
||||||
* Used by both the per-trip and all-trips subscribe modals.
|
|
||||||
*/
|
*/
|
||||||
export function SubscribeLinks({ httpsUrl, webcalUrl }: SubscribeLinksProps) {
|
export function useSubscribeLinks(httpsUrl: string, webcalUrl: string) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [copied, setCopied] = useState<'https' | 'webcal' | null>(null)
|
const [copied, setCopied] = useState<'https' | 'webcal' | null>(null)
|
||||||
|
|
||||||
@@ -41,6 +39,17 @@ export function SubscribeLinks({ httpsUrl, webcalUrl }: SubscribeLinksProps) {
|
|||||||
} catch { /* ignore */ }
|
} catch { /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const manualLinks = [
|
||||||
|
{ label: 'Google Calendar', hint: t('dashboard.ics.pasteFromUrl'), url: httpsUrl, copied: copied === 'https', onCopy: () => void copy(httpsUrl, 'https') },
|
||||||
|
{ label: 'Apple Calendar / Outlook', hint: 'webcal://', url: webcalUrl, copied: copied === 'webcal', onCopy: () => void copy(webcalUrl, 'webcal') },
|
||||||
|
]
|
||||||
|
return { googleUrl, manualLinks }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SubscribeLinks({ httpsUrl, webcalUrl }: SubscribeLinksProps) {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const { googleUrl, manualLinks } = useSubscribeLinks(httpsUrl, webcalUrl)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* One-click subscribe actions */}
|
{/* One-click subscribe actions */}
|
||||||
@@ -78,22 +87,7 @@ export function SubscribeLinks({ httpsUrl, webcalUrl }: SubscribeLinksProps) {
|
|||||||
<summary style={{ cursor: 'pointer', userSelect: 'none', marginBottom: 8 }}>
|
<summary style={{ cursor: 'pointer', userSelect: 'none', marginBottom: 8 }}>
|
||||||
{t('dashboard.ics.copyManually')}
|
{t('dashboard.ics.copyManually')}
|
||||||
</summary>
|
</summary>
|
||||||
<UrlRow
|
{manualLinks.map(link => <UrlRow key={link.label} {...link} copyLabel={t('common.copy')} />)}
|
||||||
label="Google Calendar"
|
|
||||||
copyLabel={t('common.copy')}
|
|
||||||
hint={t('dashboard.ics.pasteFromUrl')}
|
|
||||||
url={httpsUrl}
|
|
||||||
copied={copied === 'https'}
|
|
||||||
onCopy={() => copy(httpsUrl, 'https')}
|
|
||||||
/>
|
|
||||||
<UrlRow
|
|
||||||
label="Apple Calendar / Outlook"
|
|
||||||
copyLabel={t('common.copy')}
|
|
||||||
hint="webcal://"
|
|
||||||
url={webcalUrl}
|
|
||||||
copied={copied === 'webcal'}
|
|
||||||
onCopy={() => copy(webcalUrl, 'webcal')}
|
|
||||||
/>
|
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useAuthStore } from '../../store/authStore'
|
|||||||
import { useSettingsStore } from '../../store/settingsStore'
|
import { useSettingsStore } from '../../store/settingsStore'
|
||||||
import { buildUser, buildReservation } from '../../../tests/helpers/factories'
|
import { buildUser, buildReservation } from '../../../tests/helpers/factories'
|
||||||
import TransitJourneyModal from './TransitJourneyModal'
|
import TransitJourneyModal from './TransitJourneyModal'
|
||||||
|
import MTransitJourneySheet from '../../mobile/screens/trip/sheets/MTransitJourneySheet'
|
||||||
|
|
||||||
function makeReservation() {
|
function makeReservation() {
|
||||||
return {
|
return {
|
||||||
@@ -231,17 +232,7 @@ describe('TransitJourneyModal', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('TransitJourneyModal (mobile viewport)', () => {
|
describe('MTransitJourneySheet', () => {
|
||||||
const desktopWidth = window.innerWidth
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: 420 })
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: desktopWidth })
|
|
||||||
})
|
|
||||||
|
|
||||||
function makeMobileReservation() {
|
function makeMobileReservation() {
|
||||||
const res = makeReservation()
|
const res = makeReservation()
|
||||||
res.metadata = {
|
res.metadata = {
|
||||||
@@ -263,13 +254,14 @@ describe('TransitJourneyModal (mobile viewport)', () => {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
it('FE-PLANNER-TRANSITJOURNEY-015: renders the per-leg rail with platform, headsign and meta line', () => {
|
it('FE-PLANNER-TRANSITJOURNEY-015: renders the per-leg rail with platform, headsign and separate facts', () => {
|
||||||
render(<TransitJourneyModal {...makeProps({ reservation: makeMobileReservation() })} />)
|
render(<MTransitJourneySheet {...makeProps({ reservation: makeMobileReservation() })} />)
|
||||||
expect(screen.getByText('U2')).toBeInTheDocument()
|
expect(screen.getByText('U2')).toBeInTheDocument()
|
||||||
expect(screen.getByText(/Platform 2/)).toBeInTheDocument()
|
expect(screen.getByText(/Platform 2/)).toBeInTheDocument()
|
||||||
expect(screen.getByText('Ruhleben')).toBeInTheDocument()
|
expect(screen.getByText('Ruhleben')).toBeInTheDocument()
|
||||||
// mins · stops · agency collapse into one quiet line.
|
expect(screen.getByText('24 min')).toBeInTheDocument()
|
||||||
expect(screen.getByText(/24 min · 6 stops · BVG/)).toBeInTheDocument()
|
expect(screen.getByText('6 stops')).toBeInTheDocument()
|
||||||
|
expect(screen.getByText('BVG')).toBeInTheDocument()
|
||||||
expect(screen.getByText('08:36')).toBeInTheDocument()
|
expect(screen.getByText('08:36')).toBeInTheDocument()
|
||||||
// The meta-less leg falls back to its mode as the badge and shows no meta line.
|
// The meta-less leg falls back to its mode as the badge and shows no meta line.
|
||||||
expect(screen.getByText('BUS')).toBeInTheDocument()
|
expect(screen.getByText('BUS')).toBeInTheDocument()
|
||||||
@@ -280,7 +272,7 @@ describe('TransitJourneyModal (mobile viewport)', () => {
|
|||||||
const reservation = makeMobileReservation()
|
const reservation = makeMobileReservation()
|
||||||
const line = 'Melbourne Airport Express via Southern Cross'
|
const line = 'Melbourne Airport Express via Southern Cross'
|
||||||
reservation.metadata.transit.legs[1] = { ...reservation.metadata.transit.legs[1], line, line_text_color: undefined }
|
reservation.metadata.transit.legs[1] = { ...reservation.metadata.transit.legs[1], line, line_text_color: undefined }
|
||||||
render(<TransitJourneyModal {...makeProps({ reservation })} />)
|
render(<MTransitJourneySheet {...makeProps({ reservation })} />)
|
||||||
|
|
||||||
const label = screen.getByText(line)
|
const label = screen.getByText(line)
|
||||||
expect(label.parentElement).toHaveStyle({ maxInlineSize: '40%', color: '#fff' })
|
expect(label.parentElement).toHaveStyle({ maxInlineSize: '40%', color: '#fff' })
|
||||||
@@ -288,13 +280,30 @@ describe('TransitJourneyModal (mobile viewport)', () => {
|
|||||||
expect(screen.getByText('Ruhleben')).toBeInTheDocument()
|
expect(screen.getByText('Ruhleben')).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('FE-PLANNER-TRANSITJOURNEY-016: mobile stat tiles stay iconless but keep value + caption', () => {
|
it('FE-PLANNER-TRANSITJOURNEY-016: shows mobile route facts and keeps deletion behind More', async () => {
|
||||||
render(<TransitJourneyModal {...makeProps({ reservation: makeMobileReservation() })} />)
|
const user = userEvent.setup()
|
||||||
|
render(<MTransitJourneySheet {...makeProps({ reservation: makeMobileReservation() })} />)
|
||||||
expect(screen.getByText('Transfers')).toBeInTheDocument()
|
expect(screen.getByText('Transfers')).toBeInTheDocument()
|
||||||
expect(screen.getByText('Walking')).toBeInTheDocument()
|
expect(screen.getByText('Walking')).toBeInTheDocument()
|
||||||
expect(screen.getByText('1')).toBeInTheDocument()
|
expect(screen.getByText('1')).toBeInTheDocument()
|
||||||
// Delete collapses to an icon-only button on a phone.
|
expect(screen.queryByRole('button', { name: 'Delete' })).not.toBeInTheDocument()
|
||||||
const deleteBtn = screen.getByRole('button', { name: 'Delete' })
|
await user.click(screen.getByRole('button', { name: 'More' }))
|
||||||
expect(deleteBtn.textContent?.trim()).toBe('')
|
expect(screen.getByRole('button', { name: 'Delete' })).toBeVisible()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('opens the mobile journey in read mode and saves name and notes from the separate form', async () => {
|
||||||
|
const user = userEvent.setup()
|
||||||
|
const onSave = vi.fn().mockResolvedValue({})
|
||||||
|
render(<MTransitJourneySheet {...makeProps({ reservation: makeMobileReservation(), onSave })} />)
|
||||||
|
|
||||||
|
expect(screen.queryByRole('textbox')).not.toBeInTheDocument()
|
||||||
|
await user.click(screen.getByRole('button', { name: /^Edit$/ }))
|
||||||
|
const title = screen.getByDisplayValue('Fernsehturm → Zoo')
|
||||||
|
await user.clear(title)
|
||||||
|
await user.type(title, 'To the zoo')
|
||||||
|
await user.type(screen.getByRole('textbox', { name: 'Notes' }), 'Meet on the platform')
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Save' }))
|
||||||
|
|
||||||
|
expect(onSave).toHaveBeenCalledWith({ title: 'To the zoo', notes: 'Meet on the platform' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import Markdown from 'react-markdown'
|
import Markdown from 'react-markdown'
|
||||||
import remarkGfm from 'remark-gfm'
|
import remarkGfm from 'remark-gfm'
|
||||||
import remarkBreaks from 'remark-breaks'
|
import remarkBreaks from 'remark-breaks'
|
||||||
import { ArrowRight, ArrowRightLeft, Bold, CalendarDays, Clock, Code, Footprints, Heading2, Italic, Link2, List, ListChecks, MoveRight, Pencil, RefreshCw, Strikethrough, TramFront, Trash2 } from 'lucide-react'
|
import { CalendarDays, Clock, Pencil, RefreshCw } from 'lucide-react'
|
||||||
import Modal from '../shared/Modal'
|
|
||||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||||
import { DialogShell, DialogSection, DialogFooter, FooterSpacer, DialogButton, DeleteButton, PILL, fs } from '../shared/DialogShell'
|
import { DialogShell, DialogSection, DialogFooter, FooterSpacer, DialogButton, DeleteButton, PILL, fs } from '../shared/DialogShell'
|
||||||
import { Segmented, TEXTAREA } from '../shared/dialogParts'
|
import { Segmented, TEXTAREA } from '../shared/dialogParts'
|
||||||
@@ -14,10 +13,8 @@ import { deleteBodyKey } from './bookings/bookingsModel'
|
|||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
import { useSettingsStore } from '../../store/settingsStore'
|
import { useSettingsStore } from '../../store/settingsStore'
|
||||||
import { useTripStore } from '../../store/tripStore'
|
import { useTripStore } from '../../store/tripStore'
|
||||||
import { splitReservationDateTime, formatTime } from '../../utils/formatters'
|
import { TransitTitle } from './transitDisplay'
|
||||||
import { TransitTitle, TransitLineBadge, TransitMetaBadges, TransitWalkDivider, fmtTransitDuration } from './transitDisplay'
|
import { TRANSIT_NOTE_TOOLS, transitJourneyFacts, useTransitNoteFormatting, type TransitJourneyModalProps } from './transitJourneyModel'
|
||||||
import type { Reservation } from '../../types'
|
|
||||||
import { useIsPhone } from '../../mobile/useIsPhone'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The journey view for an automated public-transit entry (#1065): a roomy modal
|
* The journey view for an automated public-transit entry (#1065): a roomy modal
|
||||||
@@ -27,41 +24,11 @@ import { useIsPhone } from '../../mobile/useIsPhone'
|
|||||||
* details" hands off to the full transport editor for the booking fields
|
* details" hands off to the full transport editor for the booking fields
|
||||||
* (travelers, costs, files, code, status — #2148).
|
* (travelers, costs, files, code, status — #2148).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface TransitLegMeta {
|
|
||||||
mode?: string
|
|
||||||
line?: string | null
|
|
||||||
line_color?: string | null
|
|
||||||
line_text_color?: string | null
|
|
||||||
headsign?: string | null
|
|
||||||
agency?: string | null
|
|
||||||
duration?: number
|
|
||||||
stops?: number
|
|
||||||
from?: { name?: string; time?: string | null; track?: string | null }
|
|
||||||
to?: { name?: string; time?: string | null; track?: string | null }
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TransitJourneyModalProps {
|
|
||||||
reservation: Reservation
|
|
||||||
onClose: () => void
|
|
||||||
/** Partial field update — endpoints + itinerary stay untouched. */
|
|
||||||
onSave: (fields: { title: string; notes: string | null }) => Promise<unknown>
|
|
||||||
onDelete: () => Promise<unknown>
|
|
||||||
onChangeRoute: () => void
|
|
||||||
/** Switch to the full transport editor (travelers, costs, files, code, status). */
|
|
||||||
onEditDetails?: () => void
|
|
||||||
canEdit: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function TransitJourneyModal({ reservation, onClose, onSave, onDelete, onChangeRoute, onEditDetails, canEdit }: TransitJourneyModalProps) {
|
export default function TransitJourneyModal({ reservation, onClose, onSave, onDelete, onChangeRoute, onEditDetails, canEdit }: TransitJourneyModalProps) {
|
||||||
const { t, locale } = useTranslation()
|
const { t, locale } = useTranslation()
|
||||||
const isMobile = useIsPhone()
|
|
||||||
const timeFormat = useSettingsStore(st => st.settings.time_format) || '24h'
|
const timeFormat = useSettingsStore(st => st.settings.time_format) || '24h'
|
||||||
const budgetItems = useTripStore(st => st.budgetItems)
|
const budgetItems = useTripStore(st => st.budgetItems)
|
||||||
const res = reservation
|
const res = reservation
|
||||||
const meta = typeof res.metadata === 'string' ? (() => { try { return JSON.parse(res.metadata || '{}') } catch { return {} } })() : (res.metadata || {})
|
|
||||||
const transit = meta.transit && Array.isArray(meta.transit.legs) ? meta.transit : null
|
|
||||||
|
|
||||||
const [title, setTitle] = useState(res.title || '')
|
const [title, setTitle] = useState(res.title || '')
|
||||||
const [editingTitle, setEditingTitle] = useState(false)
|
const [editingTitle, setEditingTitle] = useState(false)
|
||||||
const [notes, setNotes] = useState(res.notes || '')
|
const [notes, setNotes] = useState(res.notes || '')
|
||||||
@@ -69,52 +36,7 @@ export default function TransitJourneyModal({ reservation, onClose, onSave, onDe
|
|||||||
const [notesTab, setNotesTab] = useState<'write' | 'preview'>(() => (res.notes ? 'preview' : 'write'))
|
const [notesTab, setNotesTab] = useState<'write' | 'preview'>(() => (res.notes ? 'preview' : 'write'))
|
||||||
const [saving, setSaving] = useState(false)
|
const [saving, setSaving] = useState(false)
|
||||||
const [confirmDelete, setConfirmDelete] = useState(false)
|
const [confirmDelete, setConfirmDelete] = useState(false)
|
||||||
const titleInputRef = useRef<HTMLInputElement | null>(null)
|
const { notesRef, applyMd } = useTransitNoteFormatting(notes, setNotes)
|
||||||
const notesRef = useRef<HTMLTextAreaElement | null>(null)
|
|
||||||
|
|
||||||
// Markdown toolbar: wrap the selection / prefix the current lines, then
|
|
||||||
// restore focus and a sensible cursor.
|
|
||||||
const applyMd = (action: { wrap?: [string, string]; linePrefix?: string }) => {
|
|
||||||
const el = notesRef.current
|
|
||||||
if (!el) return
|
|
||||||
const start = el.selectionStart ?? 0
|
|
||||||
const end = el.selectionEnd ?? 0
|
|
||||||
const value = notes
|
|
||||||
let next = value
|
|
||||||
let selStart = start
|
|
||||||
let selEnd = end
|
|
||||||
if (action.wrap) {
|
|
||||||
const [pre, post] = action.wrap
|
|
||||||
const selected = value.slice(start, end)
|
|
||||||
next = value.slice(0, start) + pre + selected + post + value.slice(end)
|
|
||||||
selStart = start + pre.length
|
|
||||||
selEnd = selStart + selected.length
|
|
||||||
} else if (action.linePrefix) {
|
|
||||||
const prefix = action.linePrefix
|
|
||||||
const lineStart = value.lastIndexOf('\n', start - 1) + 1
|
|
||||||
const block = value.slice(lineStart, end)
|
|
||||||
const prefixed = block.split('\n').map(l => prefix + l).join('\n')
|
|
||||||
next = value.slice(0, lineStart) + prefixed + value.slice(end)
|
|
||||||
selStart = start + prefix.length
|
|
||||||
selEnd = end + (prefixed.length - block.length)
|
|
||||||
}
|
|
||||||
setNotes(next)
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
el.focus()
|
|
||||||
el.setSelectionRange(selStart, selEnd)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const MD_TOOLS: { Icon: typeof Bold; label: string; action: { wrap?: [string, string]; linePrefix?: string } }[] = [
|
|
||||||
{ Icon: Bold, label: 'Bold', action: { wrap: ['**', '**'] } },
|
|
||||||
{ Icon: Italic, label: 'Italic', action: { wrap: ['*', '*'] } },
|
|
||||||
{ Icon: Strikethrough, label: 'Strikethrough', action: { wrap: ['~~', '~~'] } },
|
|
||||||
{ Icon: Heading2, label: 'Heading', action: { linePrefix: '## ' } },
|
|
||||||
{ Icon: List, label: 'List', action: { linePrefix: '- ' } },
|
|
||||||
{ Icon: ListChecks, label: 'Checklist', action: { linePrefix: '- [ ] ' } },
|
|
||||||
{ Icon: Link2, label: 'Link', action: { wrap: ['[', '](https://)'] } },
|
|
||||||
{ Icon: Code, label: 'Code', action: { wrap: ['`', '`'] } },
|
|
||||||
]
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle(res.title || '')
|
setTitle(res.title || '')
|
||||||
@@ -123,8 +45,6 @@ export default function TransitJourneyModal({ reservation, onClose, onSave, onDe
|
|||||||
setNotesTab(res.notes ? 'preview' : 'write')
|
setNotesTab(res.notes ? 'preview' : 'write')
|
||||||
}, [res.id])
|
}, [res.id])
|
||||||
|
|
||||||
useEffect(() => { if (editingTitle) titleInputRef.current?.focus() }, [editingTitle])
|
|
||||||
|
|
||||||
const dirty = title !== (res.title || '') || notes !== (res.notes || '')
|
const dirty = title !== (res.title || '') || notes !== (res.notes || '')
|
||||||
|
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
@@ -136,394 +56,109 @@ export default function TransitJourneyModal({ reservation, onClose, onSave, onDe
|
|||||||
} finally { setSaving(false) }
|
} finally { setSaving(false) }
|
||||||
}
|
}
|
||||||
|
|
||||||
const { date, time } = splitReservationDateTime(res.reservation_time)
|
const { dateStr, timeText, legs, statTiles } = transitJourneyFacts(res, t, locale, timeFormat)
|
||||||
const { time: endTime } = splitReservationDateTime(res.reservation_end_time)
|
const titleId = `transit-journey-${res.id}`
|
||||||
const dateStr = date ? new Date(date + 'T00:00:00Z').toLocaleDateString(locale, { weekday: 'long', day: 'numeric', month: 'long', timeZone: 'UTC' }) : ''
|
const header = (
|
||||||
|
<BookingDialogHeader
|
||||||
const statTiles = transit ? [
|
tone="transit"
|
||||||
{ Icon: Clock, value: transit.duration > 0 ? fmtTransitDuration(transit.duration, t) : '—', label: t('transit.durationLabel') },
|
type="transit"
|
||||||
{ Icon: ArrowRightLeft, value: String(transit.transfers ?? 0), label: t('transit.transfersLabel') },
|
labelId={titleId}
|
||||||
{ Icon: Footprints, value: transit.walk_seconds > 59 ? t('transit.min', { count: Math.round(transit.walk_seconds / 60) }) : '—', label: t('transit.walkLabel') },
|
|
||||||
] : []
|
|
||||||
|
|
||||||
if (!isMobile) {
|
|
||||||
const titleId = `transit-journey-${res.id}`
|
|
||||||
const timeText = time ? `${formatTime(time, locale, timeFormat)}${endTime ? ` – ${formatTime(endTime, locale, timeFormat)}` : ''}` : ''
|
|
||||||
const header = (
|
|
||||||
<BookingDialogHeader
|
|
||||||
tone="transit"
|
|
||||||
type="transit"
|
|
||||||
labelId={titleId}
|
|
||||||
onClose={onClose}
|
|
||||||
title={<TransitTitle title={title} iconSize={16} />}
|
|
||||||
onTitleClick={canEdit ? () => setEditingTitle(true) : undefined}
|
|
||||||
titleTooltip={t('reservations.rename')}
|
|
||||||
titleInput={editingTitle ? {
|
|
||||||
value: title,
|
|
||||||
onChange: setTitle,
|
|
||||||
label: t('reservations.titleLabel'),
|
|
||||||
autoFocus: true,
|
|
||||||
onBlur: () => setEditingTitle(false),
|
|
||||||
onKeyDown: e => {
|
|
||||||
if (e.key === 'Enter') setEditingTitle(false)
|
|
||||||
// Spent here, so the dialog stays open and only the rename is dropped.
|
|
||||||
if (e.key === 'Escape') { e.preventDefault(); setTitle(res.title || ''); setEditingTitle(false) }
|
|
||||||
},
|
|
||||||
} : undefined}
|
|
||||||
pills={(
|
|
||||||
<>
|
|
||||||
<TypePill type="transit" />
|
|
||||||
{dateStr && <span className={PILL}><CalendarDays size={13} strokeWidth={2.2} className="text-content-faint" />{dateStr}</span>}
|
|
||||||
{timeText && <span className={PILL}><Clock size={13} strokeWidth={2.2} className="text-content-faint" /><span className="tabular-nums">{timeText}</span></span>}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
const footer = (
|
|
||||||
<DialogFooter>
|
|
||||||
{canEdit && <DialogButton onClick={onChangeRoute} icon={<RefreshCw size={14} strokeWidth={2} />}>{t('transit.changeRoute')}</DialogButton>}
|
|
||||||
{canEdit && onEditDetails && <DialogButton onClick={onEditDetails} icon={<Pencil size={14} strokeWidth={2} />}>{t('transit.editDetails')}</DialogButton>}
|
|
||||||
<FooterSpacer />
|
|
||||||
{canEdit && <DeleteButton onClick={() => setConfirmDelete(true)} />}
|
|
||||||
{canEdit
|
|
||||||
? <DialogButton variant="primary" onClick={save} disabled={saving || !title.trim() || !dirty}>{saving ? t('common.saving') : t('common.save')}</DialogButton>
|
|
||||||
: <DialogButton variant="primary" onClick={onClose}>{t('common.close')}</DialogButton>}
|
|
||||||
</DialogFooter>
|
|
||||||
)
|
|
||||||
const noteTools = canEdit && (
|
|
||||||
<span className="flex items-center gap-2">
|
|
||||||
{notesTab === 'write' && (
|
|
||||||
<span className="flex gap-px rounded-[10px] bg-surface-tertiary p-[3px]">
|
|
||||||
{MD_TOOLS.map(({ Icon, label, action }) => (
|
|
||||||
<Tooltip key={label} label={label} placement="top">
|
|
||||||
<button type="button" onClick={() => applyMd(action)} aria-label={label}
|
|
||||||
className="grid h-7 w-7 place-items-center rounded-[8px] text-content-muted hover:bg-surface-card hover:text-content">
|
|
||||||
<Icon size={13} strokeWidth={2} />
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
))}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<Segmented<'write' | 'preview'>
|
|
||||||
value={notesTab}
|
|
||||||
onChange={setNotesTab}
|
|
||||||
label={t('reservations.notes')}
|
|
||||||
options={[{ value: 'write', label: t('common.edit') }, { value: 'preview', label: t('common.preview') }]}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<DialogShell onClose={onClose} labelledBy={titleId} blocked={confirmDelete} header={header} footer={footer}>
|
|
||||||
{transit && (
|
|
||||||
<div className="flex gap-2">
|
|
||||||
{statTiles.map(({ value, label }) => (
|
|
||||||
<div key={label} className="min-w-0 flex-1 rounded-[12px] bg-surface-tertiary px-3 py-2.5 text-center">
|
|
||||||
<div className="truncate font-bold tabular-nums tracking-[-0.01em] text-content" style={fs(18, 'subtitle')}>{value}</div>
|
|
||||||
<div className="mt-0.5 truncate font-geist text-content-faint" style={fs(10.5)}>{label}</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{transit && transit.legs.length > 0 && (
|
|
||||||
<DialogSection label={t('transit.itinerary')}>
|
|
||||||
<TransitLegs legs={transit.legs as TransitLegMeta[]} />
|
|
||||||
</DialogSection>
|
|
||||||
)}
|
|
||||||
<DialogSection label={t('reservations.notes')} action={noteTools}>
|
|
||||||
{canEdit && notesTab === 'write' ? (
|
|
||||||
<textarea
|
|
||||||
ref={notesRef}
|
|
||||||
value={notes}
|
|
||||||
onChange={e => setNotes(e.target.value)}
|
|
||||||
placeholder={t('reservations.notesPlaceholder')}
|
|
||||||
aria-label={t('reservations.notes')}
|
|
||||||
className={TEXTAREA}
|
|
||||||
style={{ minHeight: 130, resize: 'vertical', lineHeight: 1.55 }}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className={`rounded-[10px] border border-edge-faint bg-surface-card px-3.5 py-3 ${canEdit ? 'min-h-[130px]' : ''}`}>
|
|
||||||
{notes.trim()
|
|
||||||
? <div className="collab-note-md break-words text-content" style={fs(13, 'body')}><Markdown remarkPlugins={[remarkGfm, remarkBreaks]}>{notes}</Markdown></div>
|
|
||||||
: <span className="text-content-faint" style={fs(12.5, 'body')}>{t('reservations.notesPlaceholder')}</span>}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</DialogSection>
|
|
||||||
</DialogShell>
|
|
||||||
<ConfirmDialog
|
|
||||||
isOpen={confirmDelete}
|
|
||||||
onClose={() => setConfirmDelete(false)}
|
|
||||||
onConfirm={async () => { setConfirmDelete(false); await onDelete(); onClose() }}
|
|
||||||
title={t('reservations.confirm.deleteTitle')}
|
|
||||||
message={t(deleteBodyKey(res.id, budgetItems), { name: res.title })}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
isOpen
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={t('transit.journey')}
|
title={<TransitTitle title={title} iconSize={16} />}
|
||||||
size="2xl"
|
onTitleClick={canEdit ? () => setEditingTitle(true) : undefined}
|
||||||
footer={
|
titleTooltip={t('reservations.rename')}
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
|
titleInput={editingTitle ? {
|
||||||
{canEdit && (
|
value: title,
|
||||||
<button type="button" onClick={() => setConfirmDelete(true)} aria-label={t('common.delete')} title={t('common.delete')} style={{
|
onChange: setTitle,
|
||||||
display: 'inline-flex', alignItems: 'center', gap: 5, padding: isMobile ? '9px 11px' : '8px 14px', borderRadius: 10,
|
label: t('reservations.titleLabel'),
|
||||||
border: '1px solid rgba(239,68,68,0.3)', background: 'rgba(239,68,68,0.06)', color: '#ef4444',
|
autoFocus: true,
|
||||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: 'pointer', fontFamily: 'inherit',
|
onBlur: () => setEditingTitle(false),
|
||||||
}}>
|
onKeyDown: e => {
|
||||||
<Trash2 size={13} /> {!isMobile && t('common.delete')}
|
if (e.key === 'Enter') setEditingTitle(false)
|
||||||
</button>
|
// Spent here, so the dialog stays open and only the rename is dropped.
|
||||||
)}
|
if (e.key === 'Escape') { e.preventDefault(); setTitle(res.title || ''); setEditingTitle(false) }
|
||||||
<div style={{ flex: 1 }} />
|
},
|
||||||
{canEdit && (
|
} : undefined}
|
||||||
<button type="button" onClick={onChangeRoute} className="text-content-muted" style={{
|
pills={(
|
||||||
display: 'inline-flex', alignItems: 'center', gap: 6, padding: '8px 16px', borderRadius: 10,
|
<>
|
||||||
border: '1px solid var(--border-primary)', background: 'none',
|
<TypePill type="transit" />
|
||||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))', cursor: 'pointer', fontFamily: 'inherit',
|
{dateStr && <span className={PILL}><CalendarDays size={13} strokeWidth={2.2} className="text-content-faint" />{dateStr}</span>}
|
||||||
}}>
|
{timeText && <span className={PILL}><Clock size={13} strokeWidth={2.2} className="text-content-faint" /><span className="tabular-nums">{timeText}</span></span>}
|
||||||
<RefreshCw size={13} /> {t('transit.changeRoute')}
|
</>
|
||||||
</button>
|
)}
|
||||||
)}
|
/>
|
||||||
{canEdit && onEditDetails && (
|
)
|
||||||
<button type="button" onClick={onEditDetails} className="text-content-muted" style={{
|
const footer = (
|
||||||
display: 'inline-flex', alignItems: 'center', gap: 6, padding: '8px 16px', borderRadius: 10,
|
<DialogFooter>
|
||||||
border: '1px solid var(--border-primary)', background: 'none',
|
{canEdit && <DialogButton onClick={onChangeRoute} icon={<RefreshCw size={14} strokeWidth={2} />}>{t('transit.changeRoute')}</DialogButton>}
|
||||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))', cursor: 'pointer', fontFamily: 'inherit',
|
{canEdit && onEditDetails && <DialogButton onClick={onEditDetails} icon={<Pencil size={14} strokeWidth={2} />}>{t('transit.editDetails')}</DialogButton>}
|
||||||
}}>
|
<FooterSpacer />
|
||||||
<Pencil size={13} /> {t('transit.editDetails')}
|
{canEdit && <DeleteButton onClick={() => setConfirmDelete(true)} />}
|
||||||
</button>
|
{canEdit
|
||||||
)}
|
? <DialogButton variant="primary" onClick={save} disabled={saving || !title.trim() || !dirty}>{saving ? t('common.saving') : t('common.save')}</DialogButton>
|
||||||
{canEdit ? (
|
: <DialogButton variant="primary" onClick={onClose}>{t('common.close')}</DialogButton>}
|
||||||
<button type="button" onClick={save} disabled={saving || !title.trim() || !dirty} className="bg-[var(--text-primary)] text-[var(--bg-primary)]" style={{
|
</DialogFooter>
|
||||||
padding: '8px 20px', borderRadius: 10, border: 'none',
|
)
|
||||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600, cursor: 'pointer', fontFamily: 'inherit',
|
const noteTools = canEdit && (
|
||||||
opacity: saving || !title.trim() || !dirty ? 0.5 : 1,
|
<span className="flex items-center gap-2">
|
||||||
}}>
|
{notesTab === 'write' && (
|
||||||
{saving ? t('common.saving') : t('common.save')}
|
<span className="flex gap-px rounded-[10px] bg-surface-tertiary p-[3px]">
|
||||||
</button>
|
{TRANSIT_NOTE_TOOLS.map(({ Icon, label, action }) => (
|
||||||
) : (
|
<Tooltip key={label} label={label} placement="top">
|
||||||
<button type="button" onClick={onClose} className="bg-accent text-accent-text" style={{ padding: '8px 20px', borderRadius: 10, border: 'none', fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600, cursor: 'pointer', fontFamily: 'inherit' }}>
|
<button type="button" onClick={() => applyMd(action)} aria-label={label}
|
||||||
{t('common.close')}
|
className="grid h-7 w-7 place-items-center rounded-[8px] text-content-muted hover:bg-surface-card hover:text-content">
|
||||||
</button>
|
<Icon size={13} strokeWidth={2} />
|
||||||
)}
|
</button>
|
||||||
</div>
|
</Tooltip>
|
||||||
}
|
))}
|
||||||
>
|
</span>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 18, fontFamily: 'var(--font-system)' }}>
|
)}
|
||||||
{/* header: icon + inline-renamable title + date/time */}
|
<Segmented<'write' | 'preview'>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
|
value={notesTab}
|
||||||
<div style={{ width: isMobile ? 40 : 48, height: isMobile ? 40 : 48, flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: 13, background: '#7c3aed18' }}>
|
onChange={setNotesTab}
|
||||||
<TramFront size={isMobile ? 19 : 23} strokeWidth={1.8} color="#7c3aed" />
|
label={t('reservations.notes')}
|
||||||
|
options={[{ value: 'write', label: t('common.edit') }, { value: 'preview', label: t('common.preview') }]}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DialogShell onClose={onClose} labelledBy={titleId} blocked={confirmDelete} header={header} footer={footer}>
|
||||||
|
{statTiles.length > 0 && (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
{statTiles.map(({ value, label }) => (
|
||||||
|
<div key={label} className="min-w-0 flex-1 rounded-[12px] bg-surface-tertiary px-3 py-2.5 text-center">
|
||||||
|
<div className="truncate font-bold tabular-nums tracking-[-0.01em] text-content" style={fs(18, 'subtitle')}>{value}</div>
|
||||||
|
<div className="mt-0.5 truncate font-geist text-content-faint" style={fs(10.5)}>{label}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
|
||||||
{editingTitle ? (
|
|
||||||
<input
|
|
||||||
ref={titleInputRef}
|
|
||||||
value={title}
|
|
||||||
onChange={e => setTitle(e.target.value)}
|
|
||||||
onBlur={() => setEditingTitle(false)}
|
|
||||||
onKeyDown={e => { if (e.key === 'Enter') setEditingTitle(false); if (e.key === 'Escape') { setTitle(res.title || ''); setEditingTitle(false) } }}
|
|
||||||
className="text-content"
|
|
||||||
aria-label={t('reservations.titleLabel')}
|
|
||||||
style={{ width: '100%', border: 'none', outline: 'none', background: 'transparent', padding: 0, fontFamily: 'inherit', fontSize: 'calc(17px * var(--fs-scale-subtitle, 1))', fontWeight: 700, letterSpacing: '-0.015em', borderBottom: '1.5px solid var(--text-primary)' }}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="text-content" style={{ display: 'flex', alignItems: 'center', gap: 7, fontSize: 'calc(17px * var(--fs-scale-subtitle, 1))', fontWeight: 700, letterSpacing: '-0.015em', minWidth: 0 }}>
|
|
||||||
<span style={{ minWidth: 0, overflow: 'hidden' }}><TransitTitle title={title} iconSize={15} /></span>
|
|
||||||
{canEdit && (
|
|
||||||
<button type="button" onClick={() => setEditingTitle(true)} aria-label={t('common.edit')} title={t('common.edit')} className="text-content-faint" style={{ border: 'none', background: 'none', padding: 3, cursor: 'pointer', display: 'flex', flexShrink: 0 }}>
|
|
||||||
<Pencil size={13} strokeWidth={1.8} />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="text-content-muted" style={{ fontSize: 'calc(12.5px * var(--fs-scale-body, 1))', marginTop: 3 }}>
|
|
||||||
{[dateStr, time ? `${formatTime(time, locale, timeFormat)}${endTime ? ` – ${formatTime(endTime, locale, timeFormat)}` : ''}` : ''].filter(Boolean).join(' · ')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{transit && (
|
|
||||||
<>
|
|
||||||
{/* journey stats — three full-width tiles; iconless and flat on mobile */}
|
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: isMobile ? 6 : 10 }}>
|
|
||||||
{statTiles.map(({ Icon, value, label }, i) => (
|
|
||||||
isMobile ? (
|
|
||||||
<div key={i} className="bg-surface-tertiary" style={{ padding: '7px 6px 6px', borderRadius: 11, textAlign: 'center', minWidth: 0 }}>
|
|
||||||
<div className="text-content" style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 700, letterSpacing: '-0.01em', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{value}</div>
|
|
||||||
<div className="text-content-faint" style={{ fontSize: 'calc(9px * var(--fs-scale-caption, 1))', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.04em', marginTop: 1 }}>{label}</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div key={i} className="bg-surface-tertiary" style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '13px 16px', borderRadius: 12 }}>
|
|
||||||
<div className="bg-surface-card" style={{ width: 34, height: 34, flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: 10 }}>
|
|
||||||
<Icon size={16} strokeWidth={1.9} className="text-content-muted" />
|
|
||||||
</div>
|
|
||||||
<div style={{ minWidth: 0 }}>
|
|
||||||
<div className="text-content" style={{ fontSize: 'calc(15px * var(--fs-scale-subtitle, 1))', fontWeight: 700, letterSpacing: '-0.01em', whiteSpace: 'nowrap' }}>{value}</div>
|
|
||||||
<div className="text-content-faint" style={{ fontSize: 'calc(10.5px * var(--fs-scale-caption, 1))', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.04em' }}>{label}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* stop-by-stop itinerary */}
|
|
||||||
<div className="bg-surface-tertiary" style={{ padding: isMobile ? '11px 10px' : '14px 16px', borderRadius: 12 }}>
|
|
||||||
<div className="text-content-faint" style={{ fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.04em', marginBottom: 12 }}>
|
|
||||||
{t('transit.itinerary')}
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
||||||
{(transit.legs as TransitLegMeta[]).map((leg, i) => {
|
|
||||||
if (leg.mode === 'WALK') return <TransitWalkDivider key={i} leg={leg} t={t} size={isMobile ? 'sm' : 'md'} />
|
|
||||||
const mins = leg.duration ? Math.round(leg.duration / 60) : null
|
|
||||||
if (isMobile) {
|
|
||||||
// The wide from → to line plus the chip row doesn't fit a
|
|
||||||
// phone: each leg becomes a depart / ride / arrive rail in
|
|
||||||
// the line's color, meta as one quiet text line.
|
|
||||||
const color = leg.line_color || 'var(--text-muted)'
|
|
||||||
const metaLine = [
|
|
||||||
mins ? t('transit.min', { count: mins }) : null,
|
|
||||||
leg.stops ? t('transit.stops', { count: leg.stops }) : null,
|
|
||||||
leg.agency || null,
|
|
||||||
].filter(Boolean).join(' · ')
|
|
||||||
// Names wrap instead of clipping; the platform gets its
|
|
||||||
// own quiet line below so it never pushes the name out.
|
|
||||||
const stopName = (stop: TransitLegMeta['from']) => (
|
|
||||||
<div style={{ minWidth: 0 }}>
|
|
||||||
<div className="text-content" style={{ fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600, lineHeight: 1.35, overflowWrap: 'anywhere' }}>
|
|
||||||
{stop?.name}
|
|
||||||
</div>
|
|
||||||
{stop?.track && (
|
|
||||||
<div className="text-content-faint" style={{ fontSize: 'calc(10.5px * var(--fs-scale-caption, 1))', fontWeight: 500, marginTop: 1 }}>
|
|
||||||
{t('transit.platform', { track: stop.track })}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
const timeCell = (time?: string | null) => (
|
|
||||||
<div className="text-content-muted" style={{ fontSize: 'calc(11.5px * var(--fs-scale-caption, 1))', fontWeight: 600, textAlign: 'end', paddingTop: 1 }}>
|
|
||||||
{time || ''}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
return (
|
|
||||||
<div key={i} style={{ display: 'grid', gridTemplateColumns: '34px 14px 1fr', columnGap: 8 }}>
|
|
||||||
{timeCell(leg.from?.time)}
|
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
|
||||||
<span style={{ width: 9, height: 9, borderRadius: '50%', border: `2.5px solid ${color}`, background: 'var(--bg-tertiary)', flexShrink: 0, marginTop: 3 }} />
|
|
||||||
<span style={{ flex: 1, width: 3, borderRadius: 2, background: color, marginTop: 2 }} />
|
|
||||||
</div>
|
|
||||||
{stopName(leg.from)}
|
|
||||||
<div />
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
|
||||||
<span style={{ width: 3, borderRadius: 2, background: color }} />
|
|
||||||
</div>
|
|
||||||
<div style={{ padding: '6px 0 8px', minWidth: 0 }}>
|
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 }}>
|
|
||||||
<TransitLineBadge label={leg.line || leg.mode} besideText={Boolean(leg.headsign)} wrap style={{ background: leg.line_color || 'var(--bg-hover)', color: leg.line_color ? (leg.line_text_color || '#fff') : 'var(--text-primary)', borderRadius: 6, padding: '1px 7px', fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 700, flexShrink: 0 }} />
|
|
||||||
{leg.headsign && (
|
|
||||||
<span className="text-content-faint" style={{ display: 'inline-flex', alignItems: 'center', gap: 3, fontSize: 'calc(11px * var(--fs-scale-caption, 1))', minWidth: 0 }}>
|
|
||||||
<MoveRight size={10} style={{ flexShrink: 0 }} />
|
|
||||||
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{leg.headsign}</span>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{metaLine && (
|
|
||||||
<div className="text-content-faint" style={{ fontSize: 'calc(10.5px * var(--fs-scale-caption, 1))', marginTop: 3 }}>{metaLine}</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{timeCell(leg.to?.time)}
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
|
||||||
<span style={{ width: 9, height: 9, borderRadius: '50%', border: `2.5px solid ${color}`, background: 'var(--bg-tertiary)', marginTop: 3 }} />
|
|
||||||
</div>
|
|
||||||
{stopName(leg.to)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div key={i} style={{ display: 'flex', alignItems: 'flex-start', gap: 12 }}>
|
|
||||||
<div className="text-content-muted" style={{ width: 44, flexShrink: 0, textAlign: 'end', fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600, paddingTop: 1 }}>
|
|
||||||
{leg.from?.time || ''}
|
|
||||||
</div>
|
|
||||||
<TransitLineBadge label={leg.line || leg.mode} besideText style={{ background: leg.line_color || 'var(--bg-hover)', color: leg.line_color ? (leg.line_text_color || '#fff') : 'var(--text-primary)', borderRadius: 6, padding: '2px 8px', fontSize: 'calc(11.5px * var(--fs-scale-caption, 1))', fontWeight: 700, flexShrink: 0 }} />
|
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
|
||||||
<div className="text-content" style={{ fontSize: 'calc(13.5px * var(--fs-scale-body, 1))', fontWeight: 600, display: 'flex', alignItems: 'center', gap: 5, flexWrap: 'wrap' }}>
|
|
||||||
<span dir="auto" style={{ minWidth: 0, overflowWrap: 'anywhere' }}>{leg.from?.name}</span>
|
|
||||||
{leg.from?.track && <span className="text-content-faint" style={{ fontWeight: 500 }}>({t('transit.platform', { track: leg.from.track })})</span>}
|
|
||||||
<ArrowRight size={12} className="text-content-faint" style={{ flexShrink: 0 }} />
|
|
||||||
<span dir="auto" style={{ minWidth: 0, overflowWrap: 'anywhere' }}>{leg.to?.name}</span>
|
|
||||||
</div>
|
|
||||||
<div style={{ marginTop: 3 }}>
|
|
||||||
<TransitMetaBadges items={[
|
|
||||||
{ icon: Clock, text: leg.from?.time ? `${leg.from.time}${leg.to?.time ? ` – ${leg.to.time}` : ''}` : '' },
|
|
||||||
{ text: mins ? t('transit.min', { count: mins }) : '' },
|
|
||||||
{ text: leg.stops ? t('transit.stops', { count: leg.stops }) : '' },
|
|
||||||
{ icon: MoveRight, text: leg.headsign || '' },
|
|
||||||
{ text: leg.agency || '', dim: true },
|
|
||||||
]} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
{legs.length > 0 && (
|
||||||
{/* notes — full width, markdown */}
|
<DialogSection label={t('transit.itinerary')}>
|
||||||
<div>
|
<TransitLegs legs={legs} />
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 6, gap: 8, flexWrap: 'wrap' }}>
|
</DialogSection>
|
||||||
<label className="text-content-faint" style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.03em' }}>{t('reservations.notes')}</label>
|
)}
|
||||||
{canEdit && (
|
<DialogSection label={t('reservations.notes')} action={noteTools}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
||||||
{notesTab === 'write' && (
|
|
||||||
<div className="bg-surface-secondary" style={{ display: 'flex', borderRadius: 8, padding: 2, gap: 1 }}>
|
|
||||||
{MD_TOOLS.map(({ Icon, label, action }) => (
|
|
||||||
<button key={label} type="button" onClick={() => applyMd(action)} title={label} aria-label={label}
|
|
||||||
className="text-content-muted"
|
|
||||||
style={{ width: 26, height: 24, display: 'grid', placeItems: 'center', borderRadius: 6, border: 0, background: 'transparent', cursor: 'pointer' }}
|
|
||||||
onMouseEnter={e => { e.currentTarget.style.background = 'var(--bg-card)' }}
|
|
||||||
onMouseLeave={e => { e.currentTarget.style.background = 'transparent' }}>
|
|
||||||
<Icon size={13} strokeWidth={2} />
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="bg-surface-secondary" style={{ display: 'flex', borderRadius: 8, padding: 2, gap: 2 }}>
|
|
||||||
{([['write', t('common.edit')], ['preview', t('common.preview')]] as const).map(([tab, label]) => (
|
|
||||||
<button key={tab} type="button" onClick={() => setNotesTab(tab)}
|
|
||||||
className={notesTab === tab ? 'bg-surface-card text-content' : 'text-content-muted'}
|
|
||||||
style={{ padding: '4px 12px', fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 500, borderRadius: 6, border: 0, cursor: 'pointer', fontFamily: 'inherit', background: notesTab === tab ? undefined : 'transparent' }}>
|
|
||||||
{label}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{canEdit && notesTab === 'write' ? (
|
{canEdit && notesTab === 'write' ? (
|
||||||
<textarea
|
<textarea
|
||||||
ref={notesRef}
|
ref={notesRef}
|
||||||
value={notes}
|
value={notes}
|
||||||
onChange={e => setNotes(e.target.value)}
|
onChange={e => setNotes(e.target.value)}
|
||||||
placeholder={t('reservations.notesPlaceholder')}
|
placeholder={t('reservations.notesPlaceholder')}
|
||||||
className="w-full border border-edge rounded-[10px] px-[12px] py-[10px] text-[13px] font-[inherit] outline-none box-border text-content bg-surface-input"
|
aria-label={t('reservations.notes')}
|
||||||
|
className={TEXTAREA}
|
||||||
style={{ minHeight: 130, resize: 'vertical', lineHeight: 1.55 }}
|
style={{ minHeight: 130, resize: 'vertical', lineHeight: 1.55 }}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="bg-surface-tertiary" style={{ borderRadius: 10, padding: '12px 14px', minHeight: canEdit ? 130 : undefined }}>
|
<div className={`rounded-[10px] border border-edge-faint bg-surface-card px-3.5 py-3 ${canEdit ? 'min-h-[130px]' : ''}`}>
|
||||||
{notes.trim()
|
{notes.trim()
|
||||||
? <div className="collab-note-md text-content" style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', wordBreak: 'break-word', overflowWrap: 'anywhere' }}><Markdown remarkPlugins={[remarkGfm, remarkBreaks]}>{notes}</Markdown></div>
|
? <div className="collab-note-md break-words text-content" style={fs(13, 'body')}><Markdown remarkPlugins={[remarkGfm, remarkBreaks]}>{notes}</Markdown></div>
|
||||||
: <span className="text-content-faint" style={{ fontSize: 'calc(12.5px * var(--fs-scale-body, 1))' }}>{t('reservations.notesPlaceholder')}</span>}
|
: <span className="text-content-faint" style={fs(12.5, 'body')}>{t('reservations.notesPlaceholder')}</span>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</DialogSection>
|
||||||
</div>
|
</DialogShell>
|
||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
isOpen={confirmDelete}
|
isOpen={confirmDelete}
|
||||||
onClose={() => setConfirmDelete(false)}
|
onClose={() => setConfirmDelete(false)}
|
||||||
@@ -531,6 +166,6 @@ export default function TransitJourneyModal({ reservation, onClose, onSave, onDe
|
|||||||
title={t('reservations.confirm.deleteTitle')}
|
title={t('reservations.confirm.deleteTitle')}
|
||||||
message={t(deleteBodyKey(res.id, budgetItems), { name: res.title })}
|
message={t(deleteBodyKey(res.id, budgetItems), { name: res.title })}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
import React, { useEffect, useId, useMemo, useRef, useState } from 'react'
|
||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import tzlookup from 'tz-lookup'
|
import tzlookup from 'tz-lookup'
|
||||||
import { ArrowLeftRight, ArrowRight, Bus, CableCar, ChevronDown, ChevronUp, Clock, Footprints, MapPin, Sailboat, Search, TramFront, TrainFront, TrainFrontTunnel } from 'lucide-react'
|
import { ArrowLeftRight, ArrowRight, Bus, CableCar, ChevronDown, ChevronUp, Clock, Footprints, MapPin, Sailboat, Search, SlidersHorizontal, TramFront, TrainFront, TrainFrontTunnel } from 'lucide-react'
|
||||||
import CustomTimePicker from '../shared/CustomTimePicker'
|
import CustomTimePicker from '../shared/CustomTimePicker'
|
||||||
import { TransitLineBadge, TransitMetaBadges } from './transitDisplay'
|
import { TransitLineBadge, TransitMetaBadges } from './transitDisplay'
|
||||||
import { transitApi } from '../../api/client'
|
import { transitApi } from '../../api/client'
|
||||||
@@ -215,15 +215,17 @@ function useFloatingList(anchorRef: React.RefObject<HTMLElement | null>, open: b
|
|||||||
return pos
|
return pos
|
||||||
}
|
}
|
||||||
|
|
||||||
function StopPicker({ label, value, onPick, quickPicks, near, placeholder }: {
|
function StopPicker({ label, value, onPick, quickPicks, near, placeholder, mobile }: {
|
||||||
label: string
|
label: string
|
||||||
value: PickedPlace | null
|
value: PickedPlace | null
|
||||||
onPick: (p: PickedPlace | null) => void
|
onPick: (p: PickedPlace | null) => void
|
||||||
quickPicks: PickedPlace[]
|
quickPicks: PickedPlace[]
|
||||||
near: string | null
|
near: string | null
|
||||||
placeholder: string
|
placeholder: string
|
||||||
|
mobile?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { language } = useTranslation()
|
const { language } = useTranslation()
|
||||||
|
const fieldId = useId()
|
||||||
const [text, setText] = useState('')
|
const [text, setText] = useState('')
|
||||||
const [results, setResults] = useState<TransitPlaceResult[]>([])
|
const [results, setResults] = useState<TransitPlaceResult[]>([])
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
@@ -286,28 +288,30 @@ function StopPicker({ label, value, onPick, quickPicks, near, placeholder }: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={rootRef} style={{ position: 'relative', flex: 1, minWidth: 0 }}>
|
<div ref={rootRef} style={{ position: 'relative', flex: 1, minWidth: 0 }}>
|
||||||
<label className="block text-[11px] font-semibold text-content-faint mb-[5px] uppercase tracking-[0.03em]">{label}</label>
|
<label htmlFor={fieldId} className={mobile ? 'mb-1.5 block text-control font-medium text-m-ink' : 'mb-[5px] block text-[11px] font-semibold uppercase tracking-[0.03em] text-content-faint'}>{label}</label>
|
||||||
<div ref={fieldRef} className="bg-surface-input border border-edge" style={{ display: 'flex', alignItems: 'center', gap: 7, borderRadius: 10, padding: '0 10px', height: 38 }}>
|
<div ref={fieldRef} className={mobile
|
||||||
<MapPin size={14} className="text-content-faint" style={{ flexShrink: 0 }} />
|
? 'flex min-h-11 items-center gap-2 rounded-xl border border-m-rowbr bg-m-sheetop px-3 focus-within:ring-1 focus-within:ring-m-act'
|
||||||
|
: 'flex h-[38px] items-center gap-[7px] rounded-[10px] border border-edge bg-surface-input px-2.5'}>
|
||||||
|
<MapPin size={16} className={mobile ? 'shrink-0 text-m-muted' : 'shrink-0 text-content-faint'} aria-hidden />
|
||||||
<input
|
<input
|
||||||
|
id={fieldId}
|
||||||
value={display}
|
value={display}
|
||||||
onChange={e => search(e.target.value)}
|
onChange={e => search(e.target.value)}
|
||||||
// Opens its list on focus, so a dialog must not focus it by itself (#1302).
|
// Opens its list on focus, so a dialog must not focus it by itself (#1302).
|
||||||
data-no-autofocus
|
data-no-autofocus
|
||||||
onFocus={() => setOpen(true)}
|
onFocus={() => setOpen(true)}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
className="text-content"
|
className={mobile ? 'min-w-0 flex-1 border-0 bg-transparent py-2 text-control text-m-ink outline-none placeholder:text-m-muted'
|
||||||
style={{ border: 0, background: 'none', outline: 'none', fontSize: 'calc(13px * var(--fs-scale-body, 1))', width: '100%', fontFamily: 'inherit' }}
|
: 'w-full border-0 bg-transparent text-control text-content outline-none'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{open && listPos && suggestions.length > 0 && createPortal(
|
{open && listPos && suggestions.length > 0 && createPortal(
|
||||||
// On the page rather than inside the dialog, so a dialog that scrolls or clips
|
// On the page rather than inside the dialog, so a dialog that scrolls or clips
|
||||||
// its content cannot cut the list off before anything is typed.
|
// its content cannot cut the list off before anything is typed.
|
||||||
<div ref={listRef} className="bg-surface-card border border-edge z-[var(--z-toast)]" style={{ position: 'fixed', left: listPos.left, width: listPos.width, ...(listPos.above ? { bottom: listPos.bottom } : { top: listPos.top }), borderRadius: 10, boxShadow: 'var(--shadow-dropdown)', overflow: 'hidden', maxHeight: listPos.maxHeight, overflowY: 'auto' }}>
|
<div ref={listRef} className={`border z-[var(--z-toast)] ${mobile ? 'm-root divide-y divide-m-rowbr border-m-rowbr bg-m-sheetop' : 'border-edge bg-surface-card'}`} style={{ position: 'fixed', left: listPos.left, width: listPos.width, ...(listPos.above ? { bottom: listPos.bottom } : { top: listPos.top }), borderRadius: 12, boxShadow: 'var(--shadow-dropdown)', overflow: 'hidden', maxHeight: listPos.maxHeight, overflowY: 'auto' }}>
|
||||||
{suggestions.map(r => (
|
{suggestions.map(r => (
|
||||||
<button type="button" key={pickedPlaceKey(r)} onClick={() => pick(r)}
|
<button type="button" key={pickedPlaceKey(r)} onClick={() => pick(r)}
|
||||||
className="text-content"
|
className={`flex w-full items-center gap-2 border-0 bg-transparent px-3 py-2 text-start text-control ${mobile ? 'min-h-11 text-m-ink active:bg-m-ic' : 'text-content'}`}
|
||||||
style={{ display: 'flex', alignItems: 'center', gap: 8, width: '100%', textAlign: 'start', padding: '8px 10px', border: 'none', background: 'none', cursor: 'pointer', fontFamily: 'inherit', fontSize: 'calc(13px * var(--fs-scale-body, 1))' }}
|
|
||||||
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-hover)'}
|
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-hover)'}
|
||||||
onMouseLeave={e => e.currentTarget.style.background = 'none'}>
|
onMouseLeave={e => e.currentTarget.style.background = 'none'}>
|
||||||
<MapPin size={13} className="text-content-faint" style={{ flexShrink: 0 }} />
|
<MapPin size={13} className="text-content-faint" style={{ flexShrink: 0 }} />
|
||||||
@@ -340,7 +344,7 @@ function LineBadge({ leg, wrap = false }: { leg: TransitLeg; wrap?: boolean }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ItineraryCard({ it, tzFrom, tzTo, is12h, expanded, onToggle, onAdd, adding, late, t }: {
|
function ItineraryCard({ it, tzFrom, tzTo, is12h, expanded, onToggle, onAdd, adding, late, t, mobile }: {
|
||||||
it: TransitItinerary
|
it: TransitItinerary
|
||||||
tzFrom: string
|
tzFrom: string
|
||||||
tzTo: string
|
tzTo: string
|
||||||
@@ -349,6 +353,7 @@ function ItineraryCard({ it, tzFrom, tzTo, is12h, expanded, onToggle, onAdd, add
|
|||||||
onToggle: () => void
|
onToggle: () => void
|
||||||
onAdd: () => void
|
onAdd: () => void
|
||||||
adding: boolean
|
adding: boolean
|
||||||
|
mobile: boolean
|
||||||
/** CW-08: the next city walk this connection arrives too late for. */
|
/** CW-08: the next city walk this connection arrives too late for. */
|
||||||
late: WalkLate | null
|
late: WalkLate | null
|
||||||
t: (k: string, p?: Record<string, string | number>) => string
|
t: (k: string, p?: Record<string, string | number>) => string
|
||||||
@@ -356,8 +361,8 @@ function ItineraryCard({ it, tzFrom, tzTo, is12h, expanded, onToggle, onAdd, add
|
|||||||
const transitLegs = it.legs.filter(l => l.mode !== 'WALK')
|
const transitLegs = it.legs.filter(l => l.mode !== 'WALK')
|
||||||
const walkMins = Math.round(it.walkSeconds / 60)
|
const walkMins = Math.round(it.walkSeconds / 60)
|
||||||
return (
|
return (
|
||||||
<div className="bg-surface-card border border-edge" style={{ borderRadius: 14, overflow: 'hidden' }}>
|
<div className={`overflow-hidden rounded-[14px] border ${mobile ? 'border-m-rowbr bg-m-sheetop' : 'border-edge bg-surface-card'}`}>
|
||||||
<button type="button" onClick={onToggle} style={{ display: 'block', width: '100%', textAlign: 'start', padding: '12px 14px', border: 'none', background: 'none', cursor: 'pointer', fontFamily: 'inherit' }}>
|
<button type="button" aria-expanded={expanded} onClick={onToggle} className="block w-full border-0 bg-transparent px-3.5 py-3 text-start">
|
||||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 10, flexWrap: 'wrap' }}>
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: 10, flexWrap: 'wrap' }}>
|
||||||
<span className="text-content" style={{ fontSize: 'calc(15px * var(--fs-scale-subtitle, 1))', fontWeight: 700, letterSpacing: '-0.01em' }}>
|
<span className="text-content" style={{ fontSize: 'calc(15px * var(--fs-scale-subtitle, 1))', fontWeight: 700, letterSpacing: '-0.01em' }}>
|
||||||
{fmtTimeInTz(it.startTime, tzFrom, is12h)} – {fmtTimeInTz(it.endTime, tzTo, is12h)}
|
{fmtTimeInTz(it.startTime, tzFrom, is12h)} – {fmtTimeInTz(it.endTime, tzTo, is12h)}
|
||||||
@@ -461,8 +466,9 @@ function ItineraryCard({ it, tzFrom, tzTo, is12h, expanded, onToggle, onAdd, add
|
|||||||
<button type="button"
|
<button type="button"
|
||||||
onClick={onAdd}
|
onClick={onAdd}
|
||||||
disabled={adding}
|
disabled={adding}
|
||||||
className="bg-accent text-accent-text"
|
className={`mt-3 w-full border-0 text-control font-semibold disabled:opacity-60 ${mobile
|
||||||
style={{ marginTop: 12, width: '100%', border: 'none', borderRadius: 10, padding: '9px 0', fontWeight: 600, fontSize: 'calc(13px * var(--fs-scale-body, 1))', cursor: adding ? 'default' : 'pointer', fontFamily: 'inherit', opacity: adding ? 0.6 : 1 }}
|
? 'min-h-11 rounded-full bg-m-act px-3 py-2 text-m-actfg'
|
||||||
|
: 'rounded-[10px] bg-accent py-[9px] text-accent-text'}`}
|
||||||
>
|
>
|
||||||
{adding ? t('transit.adding') : t('transit.addToDay')}
|
{adding ? t('transit.adding') : t('transit.addToDay')}
|
||||||
</button>
|
</button>
|
||||||
@@ -491,9 +497,10 @@ interface TransitSearchPanelProps {
|
|||||||
initialTime?: string | null
|
initialTime?: string | null
|
||||||
/** CW-08: the two city walks the leg runs between; said only while the search is for their day. */
|
/** CW-08: the two city walks the leg runs between; said only while the search is for their day. */
|
||||||
walk?: WalkTransitContext | null
|
walk?: WalkTransitContext | null
|
||||||
|
mobile?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TransitSearchPanel({ day, days, places, accommodations = [], onAdd, initialFrom = null, initialTo = null, initialTime = null, walk = null }: TransitSearchPanelProps) {
|
export default function TransitSearchPanel({ day, days, places, accommodations = [], onAdd, initialFrom = null, initialTo = null, initialTime = null, walk = null, mobile = false }: TransitSearchPanelProps) {
|
||||||
const { t, language } = useTranslation()
|
const { t, language } = useTranslation()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const is12h = useSettingsStore(s => s.settings.time_format) === '12h'
|
const is12h = useSettingsStore(s => s.settings.time_format) === '12h'
|
||||||
@@ -663,6 +670,13 @@ export default function TransitSearchPanel({ day, days, places, accommodations =
|
|||||||
const tzFrom = from ? tzAt(from.lat, from.lng) : 'UTC'
|
const tzFrom = from ? tzAt(from.lat, from.lng) : 'UTC'
|
||||||
const tzTo = to ? tzAt(to.lat, to.lng) : tzFrom
|
const tzTo = to ? tzAt(to.lat, to.lng) : tzFrom
|
||||||
const canSearch = !!from && !!to && !!time && !loading
|
const canSearch = !!from && !!to && !!time && !loading
|
||||||
|
const prefOptions = [
|
||||||
|
{ value: 'best', label: t('transit.pref.best') },
|
||||||
|
{ value: 'transfers', label: t('transit.pref.transfers') },
|
||||||
|
{ value: 'walking', label: t('transit.pref.walking') },
|
||||||
|
] as const
|
||||||
|
const departOptions = [{ arrive: false, label: t('transit.depart') }, { arrive: true, label: t('transit.arrive') }]
|
||||||
|
const mobileChoice = (active: boolean) => `inline-flex min-h-10 items-center justify-center gap-1.5 rounded-full px-3 py-1.5 text-caption font-medium ${active ? 'bg-m-act text-m-actfg' : 'bg-m-sheetop text-m-ink'}`
|
||||||
|
|
||||||
const segBtn = (active: boolean): React.CSSProperties => ({
|
const segBtn = (active: boolean): React.CSSProperties => ({
|
||||||
padding: isMobile ? '6px 5px' : '6px 11px', fontSize: isMobile ? 'calc(11px * var(--fs-scale-body, 1))' : 'calc(12px * var(--fs-scale-body, 1))', borderRadius: 7, fontWeight: 500,
|
padding: isMobile ? '6px 5px' : '6px 11px', fontSize: isMobile ? 'calc(11px * var(--fs-scale-body, 1))' : 'calc(12px * var(--fs-scale-body, 1))', borderRadius: 7, fontWeight: 500,
|
||||||
@@ -675,9 +689,9 @@ export default function TransitSearchPanel({ day, days, places, accommodations =
|
|||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16, fontFamily: 'var(--font-system)' }}>
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 16, fontFamily: 'var(--font-system)' }}>
|
||||||
<WalkTransitNote walk={walkHere} />
|
<WalkTransitNote walk={walkHere} />
|
||||||
{/* from / to — stacked tight on mobile, swap button on desktop only */}
|
{/* from / to — stacked tight on mobile, swap button on desktop only */}
|
||||||
<div style={{ display: 'flex', flexDirection: isMobile ? 'column' : 'row', gap: 8, alignItems: isMobile ? 'stretch' : 'flex-end' }}>
|
<div className={mobile ? 'flex flex-col gap-2.5 rounded-[14px] bg-m-ic p-3' : `flex gap-2 ${isMobile ? 'flex-col' : 'items-end'}`}>
|
||||||
<StopPicker label={t('transit.from')} value={from} onPick={setFrom} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
<StopPicker mobile={mobile} label={t('transit.from')} value={from} onPick={setFrom} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
||||||
{!isMobile && (
|
{!mobile && !isMobile && (
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onClick={() => { const f = from; setFrom(to); setTo(f) }}
|
onClick={() => { const f = from; setFrom(to); setTo(f) }}
|
||||||
aria-label={t('transit.swap')}
|
aria-label={t('transit.swap')}
|
||||||
@@ -688,10 +702,52 @@ export default function TransitSearchPanel({ day, days, places, accommodations =
|
|||||||
<ArrowLeftRight size={15} />
|
<ArrowLeftRight size={15} />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<StopPicker label={t('transit.to')} value={to} onPick={setTo} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
<StopPicker mobile={mobile} label={t('transit.to')} value={to} onPick={setTo} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* search options — one calm card: when + how on top, modes + go below */}
|
{mobile ? (
|
||||||
|
<>
|
||||||
|
<div className="space-y-2 rounded-[14px] bg-m-ic p-3">
|
||||||
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<div className="flex min-h-11 flex-1 rounded-full bg-m-sheetop p-0.5">
|
||||||
|
{departOptions.map(({ arrive, label }) => (
|
||||||
|
<button key={label} type="button" aria-pressed={arriveBy === arrive} onClick={() => setArriveBy(arrive)}
|
||||||
|
className={`${mobileChoice(arriveBy === arrive)} min-w-0 flex-1 !px-2`}>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="min-w-[88px] flex-none">
|
||||||
|
<CustomTimePicker value={time} onChange={setTime} aria-label={t('reservations.time')} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<details className="group border-t border-m-rowbr">
|
||||||
|
<summary className="flex min-h-11 cursor-pointer list-none items-center gap-2 text-control font-medium [&::-webkit-details-marker]:hidden">
|
||||||
|
<SlidersHorizontal size={16} className="shrink-0 text-m-muted" aria-hidden />
|
||||||
|
<span className="flex-1">{t('places.filters')}</span>
|
||||||
|
{activeModes.size < MODE_GROUPS.length && <span className="rounded-full bg-m-sheetop px-2 py-1 text-caption tabular-nums">{activeModes.size}</span>}
|
||||||
|
<ChevronDown size={16} className="shrink-0 text-m-muted group-open:rotate-180" aria-hidden />
|
||||||
|
</summary>
|
||||||
|
<div className="flex flex-wrap gap-1.5 pb-2">
|
||||||
|
{prefOptions.map(({ value, label }) => (
|
||||||
|
<button key={value} type="button" aria-pressed={pref === value} onClick={() => setPref(value)} className={mobileChoice(pref === value)}>{label}</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap gap-1.5 border-t border-m-rowbr pt-2">
|
||||||
|
{MODE_GROUPS.map(({ key, labelKey, Icon }) => (
|
||||||
|
<button key={key} type="button" aria-pressed={activeModes.has(key)} onClick={() => toggleMode(key)} className={mobileChoice(activeModes.has(key))}>
|
||||||
|
<Icon size={15} strokeWidth={2} />{t(labelKey)}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
<button type="button" onClick={search} disabled={!canSearch || !day.date}
|
||||||
|
className="flex min-h-11 items-center justify-center gap-2 rounded-full bg-m-act px-4 py-2 text-control font-semibold text-m-actfg disabled:opacity-40">
|
||||||
|
<Search size={16} aria-hidden />{t(loading ? 'transit.searching' : 'transit.search')}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
<div className="bg-surface-tertiary" style={{ borderRadius: 14, padding: '12px 14px', display: 'flex', flexDirection: 'column', gap: 12 }}>
|
<div className="bg-surface-tertiary" style={{ borderRadius: 14, padding: '12px 14px', display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10, flexWrap: 'wrap' }}>
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10, flexWrap: 'wrap' }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
|
||||||
@@ -710,9 +766,9 @@ export default function TransitSearchPanel({ day, days, places, accommodations =
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-surface-secondary" style={{ display: 'flex', borderRadius: 9, padding: 3, width: isMobile ? '100%' : undefined }}>
|
<div className="bg-surface-secondary" style={{ display: 'flex', borderRadius: 9, padding: 3, width: isMobile ? '100%' : undefined }}>
|
||||||
<button type="button" onClick={() => setPref('best')} style={{ ...segBtn(pref === 'best'), flex: isMobile ? 1 : undefined }}>{t('transit.pref.best')}</button>
|
{prefOptions.map(({ value, label }) => (
|
||||||
<button type="button" onClick={() => setPref('transfers')} style={{ ...segBtn(pref === 'transfers'), flex: isMobile ? 1 : undefined }}>{t('transit.pref.transfers')}</button>
|
<button key={value} type="button" onClick={() => setPref(value)} style={{ ...segBtn(pref === value), flex: isMobile ? 1 : undefined }}>{label}</button>
|
||||||
<button type="button" onClick={() => setPref('walking')} style={{ ...segBtn(pref === 'walking'), flex: isMobile ? 1 : undefined }}>{t('transit.pref.walking')}</button>
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -751,6 +807,7 @@ export default function TransitSearchPanel({ day, days, places, accommodations =
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* results */}
|
{/* results */}
|
||||||
{loading && (
|
{loading && (
|
||||||
@@ -778,6 +835,7 @@ export default function TransitSearchPanel({ day, days, places, accommodations =
|
|||||||
onToggle={() => setExpandedIdx(expandedIdx === idx ? null : idx)}
|
onToggle={() => setExpandedIdx(expandedIdx === idx ? null : idx)}
|
||||||
onAdd={() => addItinerary(it, idx)}
|
onAdd={() => addItinerary(it, idx)}
|
||||||
adding={addingIdx === idx}
|
adding={addingIdx === idx}
|
||||||
|
mobile={mobile}
|
||||||
late={lateForWalk(walkHere, day.date ?? null, { date: dateYMDInTz(it.endTime, tzTo), time: timeHHmmInTz(it.endTime, tzTo) })}
|
late={lateForWalk(walkHere, day.date ?? null, { date: dateYMDInTz(it.endTime, tzTo), time: timeHHmmInTz(it.endTime, tzTo) })}
|
||||||
t={t}
|
t={t}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -181,14 +181,14 @@ export interface BookingFilters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Everything a person could look a booking up by: its title, type, route, codes, carrier, place and people. */
|
/** Everything a person could look a booking up by: its title, type, route, codes, carrier, place and people. */
|
||||||
export function searchText(r: Reservation, typeLabel: string): string {
|
export function searchText(r: Reservation, typeLabel: string, includeCodes = true): string {
|
||||||
const meta = parseMeta(r)
|
const meta = parseMeta(r)
|
||||||
const legs = Array.isArray(meta.legs) ? meta.legs : []
|
const legs = Array.isArray(meta.legs) ? meta.legs : []
|
||||||
return [
|
return [
|
||||||
r.title, typeLabel, r.location, r.place_name, r.accommodation_name, r.notes, r.confirmation_number,
|
r.title, typeLabel, r.location, r.place_name, r.accommodation_name, r.notes, includeCodes ? r.confirmation_number : null,
|
||||||
meta.airline, meta.flight_number, meta.train_number, meta.departure_airport, meta.arrival_airport,
|
meta.airline, meta.flight_number, meta.train_number, meta.departure_airport, meta.arrival_airport,
|
||||||
...(r.endpoints || []).flatMap(e => [e.name, e.code]),
|
...(r.endpoints || []).flatMap(e => [e.name, e.code]),
|
||||||
...legs.flatMap((l: Record<string, unknown>) => [l.confirmation_number, l.flight_number, l.airline, l.train_number]),
|
...legs.flatMap((l: Record<string, unknown> | null) => [includeCodes ? l?.confirmation_number : null, l?.flight_number, l?.airline, l?.train_number]),
|
||||||
...(r.travelers || []).map(tv => tv.username),
|
...(r.travelers || []).map(tv => tv.username),
|
||||||
].filter(v => typeof v === 'string' && v).join(' ').toLowerCase()
|
].filter(v => typeof v === 'string' && v).join(' ').toLowerCase()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,18 @@ export function listSections(groups: StatusGroups, t: (key: string) => string) {
|
|||||||
* filters in useBookingsView, remembered for the session, and shares the
|
* filters in useBookingsView, remembered for the session, and shares the
|
||||||
* predicates with the phone through bookingsModel.
|
* predicates with the phone through bookingsModel.
|
||||||
*/
|
*/
|
||||||
export function useReservationListFilter(all: Reservation[], days: Day[], memberCount: number) {
|
export function useReservationListFilter(
|
||||||
|
all: Reservation[],
|
||||||
|
days: Day[],
|
||||||
|
memberCount: number,
|
||||||
|
matches?: (reservation: Reservation) => boolean
|
||||||
|
) {
|
||||||
const [travelerFilter, setTravelerFilter] = useState<Set<number>>(new Set());
|
const [travelerFilter, setTravelerFilter] = useState<Set<number>>(new Set());
|
||||||
// The moment the tab opened: what was over by then moves into the folded Past
|
// The moment the tab opened: what was over by then moves into the folded Past
|
||||||
// section (#3156). Taken once, so a list does not reshuffle while it is read.
|
// section (#3156). Taken once, so a list does not reshuffle while it is read.
|
||||||
const [now] = useState(() => new Date());
|
const [now] = useState(() => new Date());
|
||||||
const groups = groupTransports(
|
const groups = groupTransports(
|
||||||
all.filter((r) => onTravelers(r, travelerFilter)),
|
all.filter((r) => onTravelers(r, travelerFilter) && (!matches || matches(r))),
|
||||||
days,
|
days,
|
||||||
now
|
now
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ export interface OptimizedDay {
|
|||||||
usedHotel: boolean;
|
usedHotel: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function optimizableStops(assignments: Assignment[]): Assignment[] {
|
||||||
|
return assignments.filter((a) => !a.place?.place_time && a.place?.lat != null && a.place?.lng != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canOptimizeDay(assignments: Assignment[]): boolean {
|
||||||
|
return optimizableStops(assignments).length >= 2;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimized order for a day's assignments: timed places keep their slot, the
|
* Optimized order for a day's assignments: timed places keep their slot, the
|
||||||
* remaining located stops are rerouted (optionally anchored to the day's
|
* remaining located stops are rerouted (optionally anchored to the day's
|
||||||
@@ -46,7 +54,7 @@ export function optimizeDayOrder(
|
|||||||
if (a.place?.place_time) locked.set(idx, a);
|
if (a.place?.place_time) locked.set(idx, a);
|
||||||
else movable.push(a);
|
else movable.push(a);
|
||||||
});
|
});
|
||||||
const withCoords = movable.filter((a) => a.place?.lat != null && a.place?.lng != null);
|
const withCoords = optimizableStops(dayAssignments);
|
||||||
if (withCoords.length < 2) return null;
|
if (withCoords.length < 2) return null;
|
||||||
const noCoords = movable.filter((a) => a.place?.lat == null || a.place?.lng == null);
|
const noCoords = movable.filter((a) => a.place?.lat == null || a.place?.lng == null);
|
||||||
const anchors = fromAccommodation
|
const anchors = fromAccommodation
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
import { Bold, Code, Heading2, Italic, Link2, List, ListChecks, Strikethrough } from 'lucide-react';
|
||||||
|
import { useRef } from 'react';
|
||||||
|
import type { Reservation } from '../../types';
|
||||||
|
import { parseReservationMetadata } from '../../utils/flightLegs';
|
||||||
|
import { formatTime, splitReservationDateTime } from '../../utils/formatters';
|
||||||
|
import { transitSummary } from './bookings/transitParts';
|
||||||
|
import { fmtTransitDuration } from './transitDisplay';
|
||||||
|
|
||||||
|
export interface TransitJourneyModalProps {
|
||||||
|
reservation: Reservation;
|
||||||
|
onClose: () => void;
|
||||||
|
/** Partial field update — endpoints + itinerary stay untouched. */
|
||||||
|
onSave: (fields: { title: string; notes: string | null }) => Promise<unknown>;
|
||||||
|
onDelete: () => Promise<unknown>;
|
||||||
|
onChangeRoute: () => void;
|
||||||
|
/** Switch to the full transport editor (travelers, costs, files, code, status). */
|
||||||
|
onEditDetails?: () => void;
|
||||||
|
canEdit: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function transitJourneyFacts(
|
||||||
|
reservation: Reservation,
|
||||||
|
t: Parameters<typeof fmtTransitDuration>[1],
|
||||||
|
locale: string,
|
||||||
|
timeFormat: string
|
||||||
|
) {
|
||||||
|
const { date, time } = splitReservationDateTime(reservation.reservation_time);
|
||||||
|
const { time: endTime } = splitReservationDateTime(reservation.reservation_end_time);
|
||||||
|
const timeText = time
|
||||||
|
? [time, endTime]
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((value) => formatTime(value, locale, timeFormat))
|
||||||
|
.join(' – ')
|
||||||
|
: '';
|
||||||
|
const dateStr = date
|
||||||
|
? new Date(date + 'T00:00:00Z').toLocaleDateString(locale, {
|
||||||
|
weekday: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
timeZone: 'UTC',
|
||||||
|
})
|
||||||
|
: '';
|
||||||
|
const transit = transitSummary(parseReservationMetadata(reservation));
|
||||||
|
const statTiles = transit
|
||||||
|
? [
|
||||||
|
{ value: transit.duration ? fmtTransitDuration(transit.duration, t) : '—', label: t('transit.durationLabel') },
|
||||||
|
{ value: String(transit.transfers), label: t('transit.transfersLabel') },
|
||||||
|
{
|
||||||
|
value: transit.walk > 59 ? t('transit.min', { count: Math.round(transit.walk / 60) }) : '—',
|
||||||
|
label: t('transit.walkLabel'),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [];
|
||||||
|
return { dateStr, timeText, legs: transit?.legs ?? [], statTiles };
|
||||||
|
}
|
||||||
|
|
||||||
|
type FormatAction = { wrap?: [string, string]; linePrefix?: string };
|
||||||
|
|
||||||
|
export const TRANSIT_NOTE_TOOLS: { Icon: typeof Bold; label: string; action: FormatAction }[] = [
|
||||||
|
{ Icon: Bold, label: 'Bold', action: { wrap: ['**', '**'] } },
|
||||||
|
{ Icon: Italic, label: 'Italic', action: { wrap: ['*', '*'] } },
|
||||||
|
{ Icon: Strikethrough, label: 'Strikethrough', action: { wrap: ['~~', '~~'] } },
|
||||||
|
{ Icon: Heading2, label: 'Heading', action: { linePrefix: '## ' } },
|
||||||
|
{ Icon: List, label: 'List', action: { linePrefix: '- ' } },
|
||||||
|
{ Icon: ListChecks, label: 'Checklist', action: { linePrefix: '- [ ] ' } },
|
||||||
|
{ Icon: Link2, label: 'Link', action: { wrap: ['[', '](https://)'] } },
|
||||||
|
{ Icon: Code, label: 'Code', action: { wrap: ['`', '`'] } },
|
||||||
|
];
|
||||||
|
|
||||||
|
export function useTransitNoteFormatting(notes: string, setNotes: (value: string) => void) {
|
||||||
|
const notesRef = useRef<HTMLTextAreaElement | null>(null);
|
||||||
|
// Markdown toolbar: wrap the selection / prefix the current lines, then
|
||||||
|
// restore focus and a sensible cursor.
|
||||||
|
const applyMd = (action: FormatAction) => {
|
||||||
|
const el = notesRef.current;
|
||||||
|
if (!el) return;
|
||||||
|
const start = el.selectionStart ?? 0;
|
||||||
|
const end = el.selectionEnd ?? 0;
|
||||||
|
const value = notes;
|
||||||
|
let next = value;
|
||||||
|
let selStart = start;
|
||||||
|
let selEnd = end;
|
||||||
|
if (action.wrap) {
|
||||||
|
const [pre, post] = action.wrap;
|
||||||
|
const selected = value.slice(start, end);
|
||||||
|
next = value.slice(0, start) + pre + selected + post + value.slice(end);
|
||||||
|
selStart = start + pre.length;
|
||||||
|
selEnd = selStart + selected.length;
|
||||||
|
} else if (action.linePrefix) {
|
||||||
|
const prefix = action.linePrefix;
|
||||||
|
const lineStart = value.lastIndexOf('\n', start - 1) + 1;
|
||||||
|
const block = value.slice(lineStart, end);
|
||||||
|
const prefixed = block
|
||||||
|
.split('\n')
|
||||||
|
.map((l) => prefix + l)
|
||||||
|
.join('\n');
|
||||||
|
next = value.slice(0, lineStart) + prefixed + value.slice(end);
|
||||||
|
selStart = start + prefix.length;
|
||||||
|
selEnd = end + (prefixed.length - block.length);
|
||||||
|
}
|
||||||
|
setNotes(next);
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
el.focus();
|
||||||
|
el.setSelectionRange(selStart, selEnd);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return { notesRef, applyMd };
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ export interface PlacesColumnFileImportOptions {
|
|||||||
canEdit: boolean;
|
canEdit: boolean;
|
||||||
/** The imported tours' place ids, so the places pool leaves them out at once. */
|
/** The imported tours' place ids, so the places pool leaves them out at once. */
|
||||||
onToursChanged?: (placeIds?: number[]) => void | Promise<void>;
|
onToursChanged?: (placeIds?: number[]) => void | Promise<void>;
|
||||||
/** The new tours are in, after the trip's places were read again. */
|
/** The tours finished importing and no point-only files are waiting in the places step. */
|
||||||
onImported?: (tours: TourListItem[]) => void;
|
onImported?: (tours: TourListItem[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,9 @@ export function usePlacesColumnFileImport({
|
|||||||
tripId,
|
tripId,
|
||||||
canEdit: canEdit && toursEnabled,
|
canEdit: canEdit && toursEnabled,
|
||||||
onToursChanged,
|
onToursChanged,
|
||||||
onImported,
|
onImported: (tours) => {
|
||||||
|
if (!placesFiles?.length) onImported?.(tours);
|
||||||
|
},
|
||||||
onNoTrack: setPlacesFiles,
|
onNoTrack: setPlacesFiles,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ interface RoadtripStayModalProps {
|
|||||||
* Zero clears it: the rail reads "no stay" and "nothing planned" as the same thing.
|
* Zero clears it: the rail reads "no stay" and "nothing planned" as the same thing.
|
||||||
* The visit rides along, so the stay lands on it and not on every visit of the place.
|
* The visit rides along, so the stay lands on it and not on every visit of the place.
|
||||||
*/
|
*/
|
||||||
onSave: (placeId: number, minutes: number, assignmentId?: number) => Promise<void> | void
|
onSave: (placeId: number, minutes: number, assignmentId?: number) => Promise<boolean | void> | boolean | void
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The round minus and plus beside the number. */
|
/** The round minus and plus beside the number. */
|
||||||
@@ -90,8 +90,7 @@ export default function RoadtripStayModal({ stop, onClose, onSave }: RoadtripSta
|
|||||||
if (saving) return
|
if (saving) return
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
try {
|
try {
|
||||||
await onSave(stop.placeId, value, stop.assignmentId)
|
if (await onSave(stop.placeId, value, stop.assignmentId) !== false) onClose()
|
||||||
onClose()
|
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false)
|
setSaving(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ import { generateUUID } from '../../sync/mutationQueue';
|
|||||||
import { getApiErrorMessage } from '../../types';
|
import { getApiErrorMessage } from '../../types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A route shared from Google Maps, read and appended to a day of the trip: the logic
|
* A route shared from Google Maps, read and appended to a day of the trip through
|
||||||
* behind the desktop's import dialog (GoogleRouteImport) and the large screens' sheet
|
* the desktop import dialog.
|
||||||
* (MRtRouteImportSheet), so the two cannot drift.
|
|
||||||
*
|
*
|
||||||
* A link is previewed first, the stops it names in order, and only the ones that resolved
|
* A link is previewed first, the stops it names in order, and only the ones that resolved
|
||||||
* to a place are appended, at least two of them. One request id per opening and per day
|
* to a place are appended, at least two of them. One request id per opening and per day
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ describe('useMobileNavEditor', () => {
|
|||||||
it('FE-COMP-NAVEDITOR-001: an empty value falls back to the built-in dock split', () => {
|
it('FE-COMP-NAVEDITOR-001: an empty value falls back to the built-in dock split', () => {
|
||||||
const { result } = setup({ bar: [], more: [] });
|
const { result } = setup({ bar: [], more: [] });
|
||||||
|
|
||||||
expect(ids(result.current.barItems)).toEqual(['vacay', 'journey']);
|
expect(ids(result.current.barItems)).toEqual(['collections', 'journey']);
|
||||||
expect(ids(result.current.moreItems)).toEqual(['atlas', 'collections']);
|
expect(ids(result.current.moreItems)).toEqual(['vacay', 'atlas']);
|
||||||
expect(result.current.hasMore).toBe(true);
|
expect(result.current.hasMore).toBe(true);
|
||||||
expect(result.current.barFull).toBe(true);
|
expect(result.current.barFull).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ export function tripOfflineState(
|
|||||||
* The offline state of one trip, read again each time `active` turns on (the
|
* The offline state of one trip, read again each time `active` turns on (the
|
||||||
* menu opening), so it shows the last sync rather than the one before it.
|
* menu opening), so it shows the last sync rather than the one before it.
|
||||||
*/
|
*/
|
||||||
export function useTripOfflineStatus(trip: Trip | null | undefined, active: boolean): TripOfflineState | null {
|
export function useTripOfflineStatus(
|
||||||
|
trip: Trip | null | undefined,
|
||||||
|
active: boolean,
|
||||||
|
revision = 0
|
||||||
|
): TripOfflineState | null {
|
||||||
const [state, setState] = useState<TripOfflineState | null>(null);
|
const [state, setState] = useState<TripOfflineState | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!active || !trip) return;
|
if (!active || !trip) return;
|
||||||
@@ -46,6 +50,6 @@ export function useTripOfflineStatus(trip: Trip | null | undefined, active: bool
|
|||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
};
|
};
|
||||||
}, [trip, active]);
|
}, [trip, active, revision]);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ import {
|
|||||||
BIKE_PROFILES,
|
BIKE_PROFILES,
|
||||||
importableTourTypeSchema,
|
importableTourTypeSchema,
|
||||||
type BikeProfile,
|
type BikeProfile,
|
||||||
|
type ImportableTourType,
|
||||||
type PaddleBoatType,
|
type PaddleBoatType,
|
||||||
type PaddleWaterContext,
|
type PaddleWaterContext,
|
||||||
} from '@trek/shared';
|
} from '@trek/shared';
|
||||||
import { Info } from 'lucide-react';
|
import { Info } from 'lucide-react';
|
||||||
import { useId } from 'react';
|
import { useId, type ComponentType, type ReactNode } from 'react';
|
||||||
import { useTranslation } from '../../i18n';
|
import { useTranslation } from '../../i18n';
|
||||||
import { LABEL, Segmented } from '../shared/dialogParts';
|
import { LABEL, Segmented } from '../shared/dialogParts';
|
||||||
import { DialogSection } from '../shared/DialogShell';
|
import { DialogSection } from '../shared/DialogShell';
|
||||||
@@ -22,6 +23,18 @@ const WATERS: readonly PaddleWaterContext[] = ['river', 'lake'];
|
|||||||
/** Every type a GPX file can come in as: the planner's, and ski, which is only kept (SKI-02). */
|
/** Every type a GPX file can come in as: the planner's, and ski, which is only kept (SKI-02). */
|
||||||
const IMPORT_TYPES = importableTourTypeSchema.options;
|
const IMPORT_TYPES = importableTourTypeSchema.options;
|
||||||
|
|
||||||
|
export interface GpxImportTypeFieldProps {
|
||||||
|
value: ImportableTourType;
|
||||||
|
onChange: (value: ImportableTourType) => void;
|
||||||
|
labelId: string;
|
||||||
|
types: readonly ImportableTourType[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GpxPreviewSectionProps {
|
||||||
|
label: ReactNode;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
/** A paddle import's boat and water, side by side, each chosen on purpose. */
|
/** A paddle import's boat and water, side by side, each chosen on purpose. */
|
||||||
function PaddleImportFields({ choices }: { choices: GpxImportChoicesState }) {
|
function PaddleImportFields({ choices }: { choices: GpxImportChoicesState }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -65,14 +78,22 @@ function PaddleImportFields({ choices }: { choices: GpxImportChoicesState }) {
|
|||||||
* discipline and technique (SKI-02), and for a ride (HOR-02) what the import
|
* discipline and technique (SKI-02), and for a ride (HOR-02) what the import
|
||||||
* keeps and does not work out.
|
* keeps and does not work out.
|
||||||
*/
|
*/
|
||||||
export function GpxImportTypeSection({ choices }: { choices: GpxImportChoicesState }) {
|
export function GpxImportTypeSection({
|
||||||
|
choices,
|
||||||
|
TypeField = TourTypeSelect,
|
||||||
|
Section = DialogSection,
|
||||||
|
}: {
|
||||||
|
choices: GpxImportChoicesState;
|
||||||
|
TypeField?: ComponentType<GpxImportTypeFieldProps>;
|
||||||
|
Section?: ComponentType<GpxPreviewSectionProps>;
|
||||||
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const typeLabelId = useId();
|
const typeLabelId = useId();
|
||||||
const { chosen } = choices;
|
const { chosen } = choices;
|
||||||
return (
|
return (
|
||||||
<DialogSection label={<span id={typeLabelId}>{t('tours.import.previewAs')}</span>}>
|
<Section label={<span id={typeLabelId}>{t('tours.import.previewAs')}</span>}>
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<TourTypeSelect value={chosen.type} onChange={choices.setType} labelId={typeLabelId} types={IMPORT_TYPES} />
|
<TypeField value={chosen.type} onChange={choices.setType} labelId={typeLabelId} types={IMPORT_TYPES} />
|
||||||
{chosen.type === 'bike' && (
|
{chosen.type === 'bike' && (
|
||||||
<div data-testid="gpx-preview-bike" className="min-w-0">
|
<div data-testid="gpx-preview-bike" className="min-w-0">
|
||||||
<span className={LABEL}>{t('tours.bike.profile')}</span>
|
<span className={LABEL}>{t('tours.bike.profile')}</span>
|
||||||
@@ -94,6 +115,6 @@ export function GpxImportTypeSection({ choices }: { choices: GpxImportChoicesSta
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</DialogSection>
|
</Section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import type { TourFileLeftOut, TourGpxImportFields } from '@trek/shared';
|
import type { TourFileLeftOut, TourGpxImportFields } from '@trek/shared';
|
||||||
import { AlertTriangle, Ban, Clock, FileDown, Layers, MapPin, Shapes } from 'lucide-react';
|
import { AlertTriangle, Ban, Clock, FileDown, Layers, MapPin, Shapes } from 'lucide-react';
|
||||||
import { useId, useMemo, useState } from 'react';
|
import { useId, useMemo, useState, type ComponentType, type ReactNode } from 'react';
|
||||||
import { OFM_POSITRON } from '../../constants/mapDefaults';
|
import { OFM_POSITRON } from '../../constants/mapDefaults';
|
||||||
import { useTileUrl } from '../../hooks/useTileUrl';
|
import { useTileUrl } from '../../hooks/useTileUrl';
|
||||||
import { useTranslation } from '../../i18n';
|
import { useTranslation } from '../../i18n';
|
||||||
import { useSettingsStore } from '../../store/settingsStore';
|
import { useSettingsStore } from '../../store/settingsStore';
|
||||||
|
import { computeMapViewport, TILE_SIZE_GL } from '../../utils/mapViewport';
|
||||||
import { formatDistance, formatElevation } from '../../utils/units';
|
import { formatDistance, formatElevation } from '../../utils/units';
|
||||||
import { MapViewAuto } from '../Map/MapViewAuto';
|
import { MapViewAuto } from '../Map/MapViewAuto';
|
||||||
import { SoftPill } from '../Planner/planParts';
|
import { SoftPill } from '../Planner/planParts';
|
||||||
@@ -22,13 +23,31 @@ import {
|
|||||||
} from '../shared/DialogShell';
|
} from '../shared/DialogShell';
|
||||||
import { recordedDay, recordedMinutes } from './activity/tourActivityModel';
|
import { recordedDay, recordedMinutes } from './activity/tourActivityModel';
|
||||||
import { importFields, importMissing, useGpxImportChoices } from './gpxImportChoices';
|
import { importFields, importMissing, useGpxImportChoices } from './gpxImportChoices';
|
||||||
import { GpxImportTypeSection } from './GpxImportTypeSection';
|
import {
|
||||||
|
GpxImportTypeSection,
|
||||||
|
type GpxImportTypeFieldProps,
|
||||||
|
type GpxPreviewSectionProps,
|
||||||
|
} from './GpxImportTypeSection';
|
||||||
import { InfoDot, TourNotice } from './tourParts';
|
import { InfoDot, TourNotice } from './tourParts';
|
||||||
import { formatPlannedTourDuration } from './tourPresentation';
|
import { formatPlannedTourDuration } from './tourPresentation';
|
||||||
import type { GpxPreviewFile, TourGpxImport } from './useTourGpxImport';
|
import type { GpxPreviewFile, TourGpxImport } from './useTourGpxImport';
|
||||||
|
|
||||||
|
export interface GpxPreviewFrameProps {
|
||||||
|
fileNames: readonly string[];
|
||||||
|
busy: boolean;
|
||||||
|
canImport: boolean;
|
||||||
|
confirmLabel: string;
|
||||||
|
onCancel: () => void;
|
||||||
|
onImport: () => void;
|
||||||
|
map: ReactNode;
|
||||||
|
tracks: ReactNode;
|
||||||
|
options: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
const BADGE =
|
const BADGE =
|
||||||
'inline-flex flex-none items-center rounded-full bg-surface-secondary px-2 font-geist tabular-nums leading-[20px] text-content-secondary';
|
'inline-flex flex-none items-center rounded-full bg-surface-secondary px-2 font-geist tabular-nums leading-[20px] text-content-secondary';
|
||||||
|
// Clear the map tools along the top of the compact card.
|
||||||
|
const COMPACT_MAP_PADDING = { top: 64, right: 24, bottom: 16, left: 24 }; // rtl-lint-disable: physical map viewport
|
||||||
|
|
||||||
/** ACT-01: when a track was recorded and how long it took, where every point carried a time. */
|
/** ACT-01: when a track was recorded and how long it took, where every point carried a time. */
|
||||||
function RecordedBadge({ track }: { track: GpxPreviewFile['tracks'][number] }) {
|
function RecordedBadge({ track }: { track: GpxPreviewFile['tracks'][number] }) {
|
||||||
@@ -191,14 +210,30 @@ export default function TourGpxPreviewDialog({
|
|||||||
gpxImport,
|
gpxImport,
|
||||||
initial,
|
initial,
|
||||||
offerPoints = false,
|
offerPoints = false,
|
||||||
|
frame,
|
||||||
|
typeField,
|
||||||
|
section,
|
||||||
}: {
|
}: {
|
||||||
gpxImport: TourGpxImport;
|
gpxImport: TourGpxImport;
|
||||||
initial?: TourGpxImportFields;
|
initial?: TourGpxImportFields;
|
||||||
offerPoints?: boolean;
|
offerPoints?: boolean;
|
||||||
|
frame?: ComponentType<GpxPreviewFrameProps>;
|
||||||
|
typeField?: ComponentType<GpxImportTypeFieldProps>;
|
||||||
|
section?: ComponentType<GpxPreviewSectionProps>;
|
||||||
}) {
|
}) {
|
||||||
const { preview } = gpxImport;
|
const { preview } = gpxImport;
|
||||||
if (!preview) return null;
|
if (!preview) return null;
|
||||||
return <PreviewDialog gpxImport={gpxImport} files={preview} initial={initial ?? HIKE} offerPoints={offerPoints} />;
|
return (
|
||||||
|
<PreviewDialog
|
||||||
|
gpxImport={gpxImport}
|
||||||
|
files={preview}
|
||||||
|
initial={initial ?? HIKE}
|
||||||
|
offerPoints={offerPoints}
|
||||||
|
frame={frame}
|
||||||
|
typeField={typeField}
|
||||||
|
section={section}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const HIKE: TourGpxImportFields = { tour_type: 'hike' };
|
const HIKE: TourGpxImportFields = { tour_type: 'hike' };
|
||||||
@@ -235,11 +270,17 @@ function PreviewDialog({
|
|||||||
files,
|
files,
|
||||||
initial,
|
initial,
|
||||||
offerPoints,
|
offerPoints,
|
||||||
|
frame: Frame,
|
||||||
|
typeField,
|
||||||
|
section: Section = DialogSection,
|
||||||
}: {
|
}: {
|
||||||
gpxImport: TourGpxImport;
|
gpxImport: TourGpxImport;
|
||||||
files: GpxPreviewFile[];
|
files: GpxPreviewFile[];
|
||||||
initial: TourGpxImportFields;
|
initial: TourGpxImportFields;
|
||||||
offerPoints: boolean;
|
offerPoints: boolean;
|
||||||
|
frame?: ComponentType<GpxPreviewFrameProps>;
|
||||||
|
typeField?: ComponentType<GpxImportTypeFieldProps>;
|
||||||
|
section?: ComponentType<GpxPreviewSectionProps>;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const labelId = useId();
|
const labelId = useId();
|
||||||
@@ -260,11 +301,85 @@ function PreviewDialog({
|
|||||||
[files]
|
[files]
|
||||||
);
|
);
|
||||||
const focusPoints = useMemo(() => lines.flat(), [lines]);
|
const focusPoints = useMemo(() => lines.flat(), [lines]);
|
||||||
|
// The GL map can spend its first paint waiting for its style. Give the
|
||||||
|
// compact preview an opening camera as well as a fit for the live map.
|
||||||
|
const openingCamera = useMemo(() => {
|
||||||
|
if (!Frame) return null;
|
||||||
|
return computeMapViewport(
|
||||||
|
focusPoints.map(([lat, lng]) => ({ lat, lng })),
|
||||||
|
{
|
||||||
|
tileSize: TILE_SIZE_GL,
|
||||||
|
width: 280,
|
||||||
|
height: 160,
|
||||||
|
padding: COMPACT_MAP_PADDING,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, [Frame, focusPoints]);
|
||||||
const canImport = canConfirm(fresh, addsPoints, importMissing(choices.chosen) === null) && !gpxImport.importing;
|
const canImport = canConfirm(fresh, addsPoints, importMissing(choices.chosen) === null) && !gpxImport.importing;
|
||||||
const confirmLabel = fresh > 0 ? t('tours.import.previewConfirm', { count: fresh }) : t('tours.import.pointsConfirm');
|
const confirmLabel = fresh > 0 ? t('tours.import.previewConfirm', { count: fresh }) : t('tours.import.pointsConfirm');
|
||||||
const fields = importFields(choices.chosen);
|
const fields = importFields(choices.chosen);
|
||||||
const title = files.length === 1 ? files[0].file.name : t('tours.import.previewFiles', { count: files.length });
|
const title = files.length === 1 ? files[0].file.name : t('tours.import.previewFiles', { count: files.length });
|
||||||
|
|
||||||
|
const onImport = () => {
|
||||||
|
void gpxImport.confirm(fields, { points: addsPoints });
|
||||||
|
};
|
||||||
|
const map = (
|
||||||
|
<div
|
||||||
|
data-testid="gpx-preview-map"
|
||||||
|
className={`relative flex-none overflow-hidden rounded-[14px] border border-edge-faint ${Frame ? 'h-40' : 'h-[280px]'}`}
|
||||||
|
>
|
||||||
|
<MapViewAuto
|
||||||
|
places={[]}
|
||||||
|
route={lines}
|
||||||
|
tileUrl={tileUrl}
|
||||||
|
focusPoints={focusPoints}
|
||||||
|
focusKey={files.map(({ file }) => file.name).join('|')}
|
||||||
|
fitPadding={Frame ? COMPACT_MAP_PADDING : undefined}
|
||||||
|
center={openingCamera?.center}
|
||||||
|
zoom={openingCamera?.zoom}
|
||||||
|
followSelection={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
const trackList = (
|
||||||
|
<Section label={t('tours.import.previewTracks', { count: tracks.length })}>
|
||||||
|
<ul className="m-0 flex list-none flex-col gap-1.5 p-0">
|
||||||
|
{tracks.map(({ file, track }, index) => (
|
||||||
|
<PreviewTrackRow key={`${file.name}-${index}`} name={file.name} number={index + 1} track={track} />
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<PreviewExtras
|
||||||
|
leftOut={leftOut}
|
||||||
|
offerPoints={offerPoints}
|
||||||
|
withPoints={withPoints}
|
||||||
|
onTogglePoints={() => setWithPoints((on) => !on)}
|
||||||
|
/>
|
||||||
|
{fresh === 0 && !addsPoints && (
|
||||||
|
<div className="mt-2">
|
||||||
|
<TourNotice tone="warning" icon={<AlertTriangle size={13} strokeWidth={2} />}>
|
||||||
|
{t('tours.import.previewAllDuplicates')}
|
||||||
|
</TourNotice>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Section>
|
||||||
|
);
|
||||||
|
const options = <GpxImportTypeSection choices={choices} TypeField={typeField} Section={Section} />;
|
||||||
|
if (Frame) {
|
||||||
|
return (
|
||||||
|
<Frame
|
||||||
|
fileNames={files.map(({ file }) => file.name)}
|
||||||
|
busy={gpxImport.importing}
|
||||||
|
canImport={canImport}
|
||||||
|
confirmLabel={confirmLabel}
|
||||||
|
onImport={onImport}
|
||||||
|
onCancel={gpxImport.cancel}
|
||||||
|
map={map}
|
||||||
|
tracks={trackList}
|
||||||
|
options={options}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogShell
|
<DialogShell
|
||||||
onClose={gpxImport.cancel}
|
onClose={gpxImport.cancel}
|
||||||
@@ -298,49 +413,16 @@ function PreviewDialog({
|
|||||||
data-testid="gpx-preview-import"
|
data-testid="gpx-preview-import"
|
||||||
icon={<FileDown size={14} strokeWidth={2} />}
|
icon={<FileDown size={14} strokeWidth={2} />}
|
||||||
disabled={!canImport}
|
disabled={!canImport}
|
||||||
onClick={() => void gpxImport.confirm(fields, { points: addsPoints })}
|
onClick={onImport}
|
||||||
>
|
>
|
||||||
{confirmLabel}
|
{confirmLabel}
|
||||||
</DialogButton>
|
</DialogButton>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div
|
{map}
|
||||||
data-testid="gpx-preview-map"
|
{trackList}
|
||||||
className="relative h-[280px] flex-none overflow-hidden rounded-[14px] border border-edge-faint"
|
{options}
|
||||||
>
|
|
||||||
<MapViewAuto
|
|
||||||
places={[]}
|
|
||||||
route={lines}
|
|
||||||
tileUrl={tileUrl}
|
|
||||||
focusPoints={focusPoints}
|
|
||||||
focusKey={files.map(({ file }) => file.name).join('|')}
|
|
||||||
followSelection={false}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<DialogSection label={t('tours.import.previewTracks', { count: tracks.length })}>
|
|
||||||
<ul className="m-0 flex list-none flex-col gap-1.5 p-0">
|
|
||||||
{tracks.map(({ file, track }, index) => (
|
|
||||||
<PreviewTrackRow key={`${file.name}-${index}`} name={file.name} number={index + 1} track={track} />
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
<PreviewExtras
|
|
||||||
leftOut={leftOut}
|
|
||||||
offerPoints={offerPoints}
|
|
||||||
withPoints={withPoints}
|
|
||||||
onTogglePoints={() => setWithPoints((on) => !on)}
|
|
||||||
/>
|
|
||||||
{fresh === 0 && !addsPoints && (
|
|
||||||
<div className="mt-2">
|
|
||||||
<TourNotice tone="warning" icon={<AlertTriangle size={13} strokeWidth={2} />}>
|
|
||||||
{t('tours.import.previewAllDuplicates')}
|
|
||||||
</TourNotice>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</DialogSection>
|
|
||||||
|
|
||||||
<GpxImportTypeSection choices={choices} />
|
|
||||||
</DialogShell>
|
</DialogShell>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { TourFileLeftOut, TourGpxImportFields, TourGpxPreviewTrack, TourListItem } from '@trek/shared';
|
import type { TourFileLeftOut, TourGpxImportFields, TourGpxPreviewTrack, TourListItem } from '@trek/shared';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { useTranslation } from '../../i18n';
|
import { useTranslation } from '../../i18n';
|
||||||
|
import { documentPickerAccept } from '../../native/platform';
|
||||||
import { tourRepo } from '../../repo/tourRepo';
|
import { tourRepo } from '../../repo/tourRepo';
|
||||||
import { useTripStore } from '../../store/tripStore';
|
import { useTripStore } from '../../store/tripStore';
|
||||||
import { getApiErrorCode, getApiErrorMessage } from '../../utils/apiError';
|
import { getApiErrorCode, getApiErrorMessage } from '../../utils/apiError';
|
||||||
@@ -238,7 +239,7 @@ export function useTourGpxImport({ tripId, canEdit, onToursChanged, onImported,
|
|||||||
if (!canEdit || importing || preview) return;
|
if (!canEdit || importing || preview) return;
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.type = 'file';
|
input.type = 'file';
|
||||||
input.accept = TOUR_FILE_EXTENSIONS.join(',');
|
input.accept = documentPickerAccept(TOUR_FILE_EXTENSIONS.join(','));
|
||||||
input.multiple = true;
|
input.multiple = true;
|
||||||
input.addEventListener('change', () => void importFiles(Array.from(input.files ?? [])), { once: true });
|
input.addEventListener('change', () => void importFiles(Array.from(input.files ?? [])), { once: true });
|
||||||
input.click();
|
input.click();
|
||||||
|
|||||||
@@ -128,6 +128,21 @@ describe('TripJournalLinkSection', () => {
|
|||||||
expect(await screen.findByText('Link a journal')).toBeInTheDocument();
|
expect(await screen.findByText('Link a journal')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('lets the mobile settings confirm unlinking before sending the request', async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
const requestUnlink = vi.fn<(confirm: () => void) => void>();
|
||||||
|
answer = LINKED;
|
||||||
|
render(<TripJournalLinkSection tripId={TRIP} requestUnlink={requestUnlink} />);
|
||||||
|
|
||||||
|
await user.click(await screen.findByRole('button', { name: 'Unlink' }));
|
||||||
|
expect(requestUnlink).toHaveBeenCalledOnce();
|
||||||
|
expect(deletes).toBe(0);
|
||||||
|
expect(screen.queryByText('Unlink this journal?')).not.toBeInTheDocument();
|
||||||
|
|
||||||
|
requestUnlink.mock.calls[0][0]();
|
||||||
|
await waitFor(() => expect(deletes).toBe(1));
|
||||||
|
});
|
||||||
|
|
||||||
it('FE-TJL-SECTION-006: editing access lists the trip with each one as the link holds them', async () => {
|
it('FE-TJL-SECTION-006: editing access lists the trip with each one as the link holds them', async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
answer = { ...LINKED, link: LINKED.link && { ...LINKED.link, members: [] } };
|
answer = { ...LINKED, link: LINKED.link && { ...LINKED.link, members: [] } };
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ import { useTripJournalLink, type JournalMemberChoice } from './useTripJournalLi
|
|||||||
const ROWS = 'flex flex-col gap-0.5 rounded-[14px] border border-edge-faint bg-surface-secondary p-1.5';
|
const ROWS = 'flex flex-col gap-0.5 rounded-[14px] border border-edge-faint bg-surface-secondary p-1.5';
|
||||||
const ROW = 'flex min-h-[48px] items-center gap-3 rounded-[10px] px-2.5 py-1.5';
|
const ROW = 'flex min-h-[48px] items-center gap-3 rounded-[10px] px-2.5 py-1.5';
|
||||||
const SEGMENT = 'rounded-full px-2.5 py-1 font-semibold';
|
const SEGMENT = 'rounded-full px-2.5 py-1 font-semibold';
|
||||||
/** The phone sheet's buttons, the round 38px ones its other areas use. */
|
|
||||||
const SHEET_BUTTON =
|
const SHEET_BUTTON =
|
||||||
'flex h-[38px] min-w-0 items-center justify-center gap-1.5 whitespace-nowrap rounded-full px-3 [&>svg]:flex-none text-[length:calc(12px*var(--fs-scale-body,1))] font-semibold disabled:opacity-40';
|
'flex min-h-11 min-w-0 items-center justify-center gap-1.5 rounded-full px-3 py-2 text-control font-semibold [&>svg]:flex-none disabled:opacity-40';
|
||||||
|
|
||||||
const ROLES: { value: TripJournalLinkRole | null; labelKey: string }[] = [
|
const ROLES: { value: TripJournalLinkRole | null; labelKey: string }[] = [
|
||||||
{ value: null, labelKey: 'trip.journal.roleNone' },
|
{ value: null, labelKey: 'trip.journal.roleNone' },
|
||||||
@@ -29,7 +28,15 @@ const ROLES: { value: TripJournalLinkRole | null; labelKey: string }[] = [
|
|||||||
* Hidden with the Journey addon off, and for someone who can neither link one
|
* Hidden with the Journey addon off, and for someone who can neither link one
|
||||||
* nor see one that is linked.
|
* nor see one that is linked.
|
||||||
*/
|
*/
|
||||||
export function TripJournalLinkSection({ tripId, framed = true }: { tripId: number; framed?: boolean }) {
|
export function TripJournalLinkSection({
|
||||||
|
tripId,
|
||||||
|
framed = true,
|
||||||
|
requestUnlink,
|
||||||
|
}: {
|
||||||
|
tripId: number;
|
||||||
|
framed?: boolean;
|
||||||
|
requestUnlink?: (confirm: () => void) => void;
|
||||||
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const j = useTripJournalLink(tripId);
|
const j = useTripJournalLink(tripId);
|
||||||
const [askUnlink, setAskUnlink] = useState(false);
|
const [askUnlink, setAskUnlink] = useState(false);
|
||||||
@@ -37,34 +44,57 @@ export function TripJournalLinkSection({ tripId, framed = true }: { tripId: numb
|
|||||||
|
|
||||||
// The desktop dialog names the area above it already; the phone sheet gets the card with its own title.
|
// The desktop dialog names the area above it already; the phone sheet gets the card with its own title.
|
||||||
const Frame = framed ? JournalCard : Bare;
|
const Frame = framed ? JournalCard : Bare;
|
||||||
|
const unlink = () => {
|
||||||
|
void j.unlink();
|
||||||
|
};
|
||||||
|
const askToUnlink = () => {
|
||||||
|
if (requestUnlink) requestUnlink(unlink);
|
||||||
|
else setAskUnlink(true);
|
||||||
|
};
|
||||||
|
const saveLabel = j.mode === 'pick' ? t('trip.journal.linkSubmit') : t('common.save');
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Frame>
|
<Frame>
|
||||||
{j.mode === 'view' && <JournalView j={j} framed={framed} onUnlink={() => setAskUnlink(true)} />}
|
{j.mode === 'view' && <JournalView j={j} framed={framed} onUnlink={askToUnlink} />}
|
||||||
{j.mode === 'pick' && <JournalPicker j={j} />}
|
{j.mode === 'pick' && <JournalPicker j={j} mobile={framed} />}
|
||||||
{(j.mode === 'members' || (j.mode === 'pick' && j.pickedId != null)) && <MemberChooser j={j} />}
|
{(j.mode === 'members' || (j.mode === 'pick' && j.pickedId != null)) && <MemberChooser j={j} mobile={framed} />}
|
||||||
{j.mode !== 'view' && (
|
{j.mode !== 'view' &&
|
||||||
<div className="flex justify-end gap-2">
|
(framed ? (
|
||||||
<DialogButton onClick={j.cancel} disabled={j.busy}>
|
<div className="flex flex-wrap justify-end gap-2">
|
||||||
{t('common.cancel')}
|
<button type="button" className={`${SHEET_BUTTON} bg-m-sheetop`} onClick={j.cancel} disabled={j.busy}>
|
||||||
</DialogButton>
|
{t('common.cancel')}
|
||||||
<DialogButton
|
</button>
|
||||||
variant="primary"
|
<button
|
||||||
onClick={() => void j.save()}
|
type="button"
|
||||||
disabled={!j.canSave}
|
className={`${SHEET_BUTTON} bg-m-act text-m-actfg`}
|
||||||
icon={<Link2 size={14} strokeWidth={2.2} />}
|
onClick={() => void j.save()}
|
||||||
>
|
disabled={!j.canSave}
|
||||||
{j.mode === 'pick' ? t('trip.journal.linkSubmit') : t('common.save')}
|
>
|
||||||
</DialogButton>
|
{saveLabel}
|
||||||
</div>
|
</button>
|
||||||
)}
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<DialogButton onClick={j.cancel} disabled={j.busy}>
|
||||||
|
{t('common.cancel')}
|
||||||
|
</DialogButton>
|
||||||
|
<DialogButton
|
||||||
|
variant="primary"
|
||||||
|
onClick={() => void j.save()}
|
||||||
|
disabled={!j.canSave}
|
||||||
|
icon={<Link2 size={14} strokeWidth={2.2} />}
|
||||||
|
>
|
||||||
|
{saveLabel}
|
||||||
|
</DialogButton>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</Frame>
|
</Frame>
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
isOpen={askUnlink}
|
isOpen={askUnlink}
|
||||||
onClose={() => setAskUnlink(false)}
|
onClose={() => setAskUnlink(false)}
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
setAskUnlink(false);
|
setAskUnlink(false);
|
||||||
void j.unlink();
|
unlink();
|
||||||
}}
|
}}
|
||||||
title={t('trip.journal.unlinkTitle')}
|
title={t('trip.journal.unlinkTitle')}
|
||||||
message={t('trip.journal.unlinkMessage')}
|
message={t('trip.journal.unlinkMessage')}
|
||||||
@@ -80,7 +110,17 @@ export function TripJournalLinkSection({ tripId, framed = true }: { tripId: numb
|
|||||||
*/
|
*/
|
||||||
function JournalView({ j, framed, onUnlink }: { j: JournalLink; framed: boolean; onUnlink: () => void }) {
|
function JournalView({ j, framed, onUnlink }: { j: JournalLink; framed: boolean; onUnlink: () => void }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (!j.link) return j.canLink ? <AddRowButton onClick={j.startPick}>{t('trip.journal.link')}</AddRowButton> : null;
|
if (!j.link) {
|
||||||
|
if (!j.canLink) return null;
|
||||||
|
return framed ? (
|
||||||
|
<button type="button" className={`${SHEET_BUTTON} w-full bg-m-act text-m-actfg`} onClick={j.startPick}>
|
||||||
|
<Link2 size={16} aria-hidden />
|
||||||
|
{t('trip.journal.link')}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<AddRowButton onClick={j.startPick}>{t('trip.journal.link')}</AddRowButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!framed) return <LinkedJournalCards j={j} onUnlink={onUnlink} />;
|
if (!framed) return <LinkedJournalCards j={j} onUnlink={onUnlink} />;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -104,11 +144,7 @@ function SheetActions({ j, onUnlink }: { j: JournalLink; onUnlink: () => void })
|
|||||||
{(j.canLink || j.canUnlink) && (
|
{(j.canLink || j.canUnlink) && (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
{j.canLink && (
|
{j.canLink && (
|
||||||
<button
|
<button type="button" onClick={j.startPick} className={`${SHEET_BUTTON} flex-1 bg-m-sheetop text-m-ink`}>
|
||||||
type="button"
|
|
||||||
onClick={j.startPick}
|
|
||||||
className={`${SHEET_BUTTON} flex-1 bg-[color:var(--m-ic)] text-m-ink`}
|
|
||||||
>
|
|
||||||
<BookOpen size={14} strokeWidth={2.2} />
|
<BookOpen size={14} strokeWidth={2.2} />
|
||||||
{t('trip.journal.change')}
|
{t('trip.journal.change')}
|
||||||
</button>
|
</button>
|
||||||
@@ -118,7 +154,7 @@ function SheetActions({ j, onUnlink }: { j: JournalLink; onUnlink: () => void })
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onUnlink}
|
onClick={onUnlink}
|
||||||
disabled={j.busy}
|
disabled={j.busy}
|
||||||
className={`${SHEET_BUTTON} flex-1 bg-[color:var(--m-ic)] text-[color:var(--m-st-danger)]`}
|
className={`${SHEET_BUTTON} flex-1 bg-m-sheetop text-[color:var(--m-st-danger)]`}
|
||||||
>
|
>
|
||||||
<Unlink size={14} strokeWidth={2.2} />
|
<Unlink size={14} strokeWidth={2.2} />
|
||||||
{t('trip.journal.unlink')}
|
{t('trip.journal.unlink')}
|
||||||
@@ -134,8 +170,8 @@ function SheetActions({ j, onUnlink }: { j: JournalLink; onUnlink: () => void })
|
|||||||
function JournalCard({ children }: { children: ReactNode }) {
|
function JournalCard({ children }: { children: ReactNode }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<section className="flex flex-col gap-3 rounded-[18px] border border-[color:var(--m-inbr)] bg-[color:var(--m-inner)] p-3">
|
<section className="flex flex-col gap-3 rounded-[14px] bg-m-ic p-3">
|
||||||
<p className="m-0 font-geist text-caption leading-snug text-m-muted">{t('trip.journal.hint')}</p>
|
<p className="m-0 text-caption leading-snug text-m-muted">{t('trip.journal.hint')}</p>
|
||||||
{children}
|
{children}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
@@ -253,8 +289,8 @@ function LinkedJournal({ j }: { j: JournalLink }) {
|
|||||||
const members = link.members ?? [];
|
const members = link.members ?? [];
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<div className="flex items-center gap-3 rounded-[14px] bg-[color:var(--m-ic)] p-2">
|
<div className="flex items-center gap-3 rounded-xl bg-m-sheetop p-2">
|
||||||
<span className="grid h-11 w-11 flex-none place-items-center overflow-hidden rounded-[11px] bg-m-card text-m-muted">
|
<span className="grid h-11 w-11 flex-none place-items-center overflow-hidden rounded-lg bg-m-ic text-m-muted">
|
||||||
{link.cover_image ? (
|
{link.cover_image ? (
|
||||||
<img src={`/uploads/${link.cover_image}`} alt="" className="h-full w-full object-cover" />
|
<img src={`/uploads/${link.cover_image}`} alt="" className="h-full w-full object-cover" />
|
||||||
) : (
|
) : (
|
||||||
@@ -275,7 +311,7 @@ function LinkedJournal({ j }: { j: JournalLink }) {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{members.length > 0 ? (
|
{members.length > 0 ? (
|
||||||
<div className="flex flex-col">
|
<div className="divide-y divide-m-rowbr rounded-xl bg-m-sheetop px-2.5">
|
||||||
{members.map((m) => (
|
{members.map((m) => (
|
||||||
<div key={m.user_id} className="flex items-center gap-2.5 py-1.5">
|
<div key={m.user_id} className="flex items-center gap-2.5 py-1.5">
|
||||||
<TripMemberAvatar username={m.username} avatarUrl={m.avatar_url} size={30} />
|
<TripMemberAvatar username={m.username} avatarUrl={m.avatar_url} size={30} />
|
||||||
@@ -294,7 +330,7 @@ function LinkedJournal({ j }: { j: JournalLink }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The journals of one's own to choose from; one only contributed to is not one's to give away. */
|
/** The journals of one's own to choose from; one only contributed to is not one's to give away. */
|
||||||
function JournalPicker({ j }: { j: JournalLink }) {
|
function JournalPicker({ j, mobile }: { j: JournalLink; mobile: boolean }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (j.journals == null) return <div className="h-10 animate-pulse rounded-[10px] bg-surface-tertiary" />;
|
if (j.journals == null) return <div className="h-10 animate-pulse rounded-[10px] bg-surface-tertiary" />;
|
||||||
if (j.journals.length === 0)
|
if (j.journals.length === 0)
|
||||||
@@ -313,7 +349,7 @@ function JournalPicker({ j }: { j: JournalLink }) {
|
|||||||
...j.journals.map((journal) => ({ value: String(journal.id), label: journal.title })),
|
...j.journals.map((journal) => ({ value: String(journal.id), label: journal.title })),
|
||||||
]}
|
]}
|
||||||
searchable
|
searchable
|
||||||
size="sm"
|
size={mobile ? 'md' : 'sm'}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -323,7 +359,7 @@ function JournalPicker({ j }: { j: JournalLink }) {
|
|||||||
* people the link would let in for the first time are named: from then on they
|
* people the link would let in for the first time are named: from then on they
|
||||||
* see the journal in their own Journey list as well.
|
* see the journal in their own Journey list as well.
|
||||||
*/
|
*/
|
||||||
function MemberChooser({ j }: { j: JournalLink }) {
|
function MemberChooser({ j, mobile }: { j: JournalLink; mobile: boolean }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (j.candidates == null) return <div className="h-24 animate-pulse rounded-[14px] bg-surface-tertiary" />;
|
if (j.candidates == null) return <div className="h-24 animate-pulse rounded-[14px] bg-surface-tertiary" />;
|
||||||
if (j.candidates.length === 0)
|
if (j.candidates.length === 0)
|
||||||
@@ -334,35 +370,47 @@ function MemberChooser({ j }: { j: JournalLink }) {
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2.5">
|
<div className="flex flex-col gap-2.5">
|
||||||
<div className="flex items-center justify-between gap-2">
|
<div className={mobile ? 'space-y-2' : 'flex items-center justify-between gap-2'}>
|
||||||
<span className="font-semibold text-content-secondary" style={fs(12, 'body')}>
|
<span
|
||||||
|
className={mobile ? 'text-control font-semibold' : 'font-semibold text-content-secondary'}
|
||||||
|
style={mobile ? undefined : fs(12, 'body')}
|
||||||
|
>
|
||||||
{t('trip.journal.members')}
|
{t('trip.journal.members')}
|
||||||
</span>
|
</span>
|
||||||
<div className="flex gap-1.5">
|
<div className={mobile ? 'flex flex-wrap gap-2' : 'flex gap-1.5'}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => j.setAll('viewer')}
|
onClick={() => j.setAll('viewer')}
|
||||||
className="text-content-muted hover:text-content"
|
className={mobile ? `${SHEET_BUTTON} bg-m-sheetop` : 'text-content-muted hover:text-content'}
|
||||||
style={fs(11.5)}
|
style={mobile ? undefined : fs(11.5)}
|
||||||
>
|
>
|
||||||
{t('trip.journal.allRead')}
|
{t('trip.journal.allRead')}
|
||||||
</button>
|
</button>
|
||||||
<span className="text-content-faint" aria-hidden>
|
{!mobile && (
|
||||||
/
|
<span className="text-content-faint" aria-hidden>
|
||||||
</span>
|
/
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => j.setAll(null)}
|
onClick={() => j.setAll(null)}
|
||||||
className="text-content-muted hover:text-content"
|
className={mobile ? `${SHEET_BUTTON} bg-m-sheetop` : 'text-content-muted hover:text-content'}
|
||||||
style={fs(11.5)}
|
style={mobile ? undefined : fs(11.5)}
|
||||||
>
|
>
|
||||||
{t('trip.journal.allNone')}
|
{t('trip.journal.allNone')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={ROWS}>
|
<div className={mobile ? 'divide-y divide-m-rowbr rounded-xl bg-m-sheetop px-2.5' : ROWS}>
|
||||||
{j.candidates.map((c) => (
|
{j.candidates.map((c) => (
|
||||||
<MemberRow key={c.user_id} c={c} choice={j.choice} onRole={j.setRole} showAccess={j.mode === 'pick'} />
|
<MemberRow
|
||||||
|
key={c.user_id}
|
||||||
|
c={c}
|
||||||
|
choice={j.choice}
|
||||||
|
onRole={j.setRole}
|
||||||
|
showAccess={j.mode === 'pick'}
|
||||||
|
mobile={mobile}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{j.newlyGranted.length > 0 && (
|
{j.newlyGranted.length > 0 && (
|
||||||
@@ -385,16 +433,18 @@ function MemberRow({
|
|||||||
choice,
|
choice,
|
||||||
onRole,
|
onRole,
|
||||||
showAccess,
|
showAccess,
|
||||||
|
mobile,
|
||||||
}: {
|
}: {
|
||||||
c: TripJournalCandidate;
|
c: TripJournalCandidate;
|
||||||
choice: JournalMemberChoice;
|
choice: JournalMemberChoice;
|
||||||
onRole: (userId: number, role: TripJournalLinkRole | null) => void;
|
onRole: (userId: number, role: TripJournalLinkRole | null) => void;
|
||||||
showAccess: boolean;
|
showAccess: boolean;
|
||||||
|
mobile: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const current = choice[c.user_id] ?? null;
|
const current = choice[c.user_id] ?? null;
|
||||||
return (
|
return (
|
||||||
<div className={ROW}>
|
<div className={mobile ? 'flex min-h-12 flex-wrap items-center gap-2 py-2' : ROW}>
|
||||||
<TripMemberAvatar username={c.username} avatarUrl={c.avatar_url} />
|
<TripMemberAvatar username={c.username} avatarUrl={c.avatar_url} />
|
||||||
<div className="flex min-w-0 flex-1 flex-wrap items-center gap-1.5">
|
<div className="flex min-w-0 flex-1 flex-wrap items-center gap-1.5">
|
||||||
<span className="truncate font-semibold text-content" style={fs(13, 'body')}>
|
<span className="truncate font-semibold text-content" style={fs(13, 'body')}>
|
||||||
@@ -417,7 +467,11 @@ function MemberRow({
|
|||||||
<div
|
<div
|
||||||
role="radiogroup"
|
role="radiogroup"
|
||||||
aria-label={c.username}
|
aria-label={c.username}
|
||||||
className="flex flex-none gap-0.5 rounded-full bg-surface-card p-0.5 ring-1 ring-edge-faint"
|
className={
|
||||||
|
mobile
|
||||||
|
? 'flex w-full gap-0.5 rounded-full bg-m-ic p-1'
|
||||||
|
: 'flex flex-none gap-0.5 rounded-full bg-surface-card p-0.5 ring-1 ring-edge-faint'
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{ROLES.map((r) => (
|
{ROLES.map((r) => (
|
||||||
<button
|
<button
|
||||||
@@ -426,8 +480,12 @@ function MemberRow({
|
|||||||
role="radio"
|
role="radio"
|
||||||
aria-checked={current === r.value}
|
aria-checked={current === r.value}
|
||||||
onClick={() => onRole(c.user_id, r.value)}
|
onClick={() => onRole(c.user_id, r.value)}
|
||||||
className={`${SEGMENT} ${current === r.value ? 'bg-accent text-accent-text' : 'text-content-muted hover:text-content'}`}
|
className={
|
||||||
style={fs(11, 'body')}
|
mobile
|
||||||
|
? `min-h-9 min-w-0 flex-1 rounded-full px-1.5 py-1 text-caption font-medium ${current === r.value ? 'bg-m-act text-m-actfg' : 'text-m-ink'}`
|
||||||
|
: `${SEGMENT} ${current === r.value ? 'bg-accent text-accent-text' : 'text-content-muted hover:text-content'}`
|
||||||
|
}
|
||||||
|
style={mobile ? undefined : fs(11, 'body')}
|
||||||
>
|
>
|
||||||
{t(r.labelKey)}
|
{t(r.labelKey)}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { type DateField, dateFieldOrder, dateLayout, formatDisplayDate } from '.
|
|||||||
import { useDateFormat } from '../../hooks/useDateFormat';
|
import { useDateFormat } from '../../hooks/useDateFormat';
|
||||||
import { useRemeasureSignal } from '../../hooks/useAnchoredPosition';
|
import { useRemeasureSignal } from '../../hooks/useAnchoredPosition';
|
||||||
import { useWeekStartDay } from '../../hooks/useWeekStartDay';
|
import { useWeekStartDay } from '../../hooks/useWeekStartDay';
|
||||||
|
import { useOverlay } from '../../hooks/overlayStack';
|
||||||
import { leadingBlanks, weekdayLabels } from '../../utils/calendarWeek';
|
import { leadingBlanks, weekdayLabels } from '../../utils/calendarWeek';
|
||||||
import { selectionHaptic } from '../../native/haptics';
|
import { selectionHaptic } from '../../native/haptics';
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ interface CustomDatePickerProps {
|
|||||||
max?: string;
|
max?: string;
|
||||||
/** What the field is, for a picker without a visible label around it; the trigger reads it with its date. */
|
/** What the field is, for a picker without a visible label around it; the trigger reads it with its date. */
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
|
clearLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CustomDatePicker({
|
export function CustomDatePicker({
|
||||||
@@ -46,6 +48,7 @@ export function CustomDatePicker({
|
|||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
ariaLabel,
|
ariaLabel,
|
||||||
|
clearLabel,
|
||||||
}: CustomDatePickerProps) {
|
}: CustomDatePickerProps) {
|
||||||
const { locale, t } = useTranslation();
|
const { locale, t } = useTranslation();
|
||||||
const weekStart = useWeekStartDay();
|
const weekStart = useWeekStartDay();
|
||||||
@@ -203,6 +206,7 @@ export function CustomDatePicker({
|
|||||||
|
|
||||||
const [textInput, setTextInput] = useState('');
|
const [textInput, setTextInput] = useState('');
|
||||||
const [isTyping, setIsTyping] = useState(false);
|
const [isTyping, setIsTyping] = useState(false);
|
||||||
|
useOverlay(open || isTyping, () => { setOpen(false); setIsTyping(false); }, true);
|
||||||
|
|
||||||
const handleTextSubmit = () => {
|
const handleTextSubmit = () => {
|
||||||
setIsTyping(false);
|
setIsTyping(false);
|
||||||
@@ -677,7 +681,7 @@ export function CustomDatePicker({
|
|||||||
onChange('');
|
onChange('');
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
aria-label={t('common.datepicker.clearDate')}
|
aria-label={clearLabel ?? t('common.datepicker.clearDate')}
|
||||||
style={{
|
style={{
|
||||||
background: 'none',
|
background: 'none',
|
||||||
border: 'none',
|
border: 'none',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useState, useRef, useEffect, useId } from 'react'
|
|||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import { ChevronDown, Check } from 'lucide-react'
|
import { ChevronDown, Check } from 'lucide-react'
|
||||||
import { scrollAnchorIntoView } from '../../hooks/useAnchoredPosition'
|
import { scrollAnchorIntoView } from '../../hooks/useAnchoredPosition'
|
||||||
|
import { useOverlay } from '../../hooks/overlayStack'
|
||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
import { selectionHaptic } from '../../native/haptics'
|
import { selectionHaptic } from '../../native/haptics'
|
||||||
import { useAnchoredPopover } from './useAnchoredPopover'
|
import { useAnchoredPopover } from './useAnchoredPopover'
|
||||||
@@ -99,6 +100,9 @@ export default function CustomSelect({
|
|||||||
// resizes the viewport, instead of freezing at the rect measured on open (#1999).
|
// resizes the viewport, instead of freezing at the rect measured on open (#1999).
|
||||||
const { open, bounded, box: anchored, setOpen } = useAnchoredPopover(ref, { disabled })
|
const { open, bounded, box: anchored, setOpen } = useAnchoredPopover(ref, { disabled })
|
||||||
const menuOpen = open && (!bounded || !!anchored)
|
const menuOpen = open && (!bounded || !!anchored)
|
||||||
|
const formRect = menuOpen && !bounded ? ref.current?.closest('.m-form-sheet .m-fs-body')?.getBoundingClientRect() : undefined
|
||||||
|
const expandedWidth = formRect && anchored ? Math.min(MENU_MAX_WIDTH, formRect.width - 36) : 0
|
||||||
|
const expandMenu = Boolean(formRect && anchored && expandedWidth > anchored.width + 12)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!menuOpen || !searchable || !searchRef.current) return
|
if (!menuOpen || !searchable || !searchRef.current) return
|
||||||
@@ -161,14 +165,11 @@ export default function CustomSelect({
|
|||||||
setSearch('')
|
setSearch('')
|
||||||
triggerRef.current?.focus()
|
triggerRef.current?.focus()
|
||||||
}
|
}
|
||||||
|
useOverlay(open, closeMenu, true)
|
||||||
|
|
||||||
const handleKeyDown = (event: React.KeyboardEvent) => {
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
||||||
if (disabled) return
|
if (disabled) return
|
||||||
if (event.key === 'Escape' && open) {
|
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
||||||
event.preventDefault()
|
|
||||||
event.stopPropagation()
|
|
||||||
closeMenu()
|
|
||||||
} else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const backwards = event.key === 'ArrowUp'
|
const backwards = event.key === 'ArrowUp'
|
||||||
if (!open) {
|
if (!open) {
|
||||||
@@ -191,6 +192,7 @@ export default function CustomSelect({
|
|||||||
ref={triggerRef}
|
ref={triggerRef}
|
||||||
id={id}
|
id={id}
|
||||||
data-field-trigger=""
|
data-field-trigger=""
|
||||||
|
data-select-has-badge={selected?.badge && !selected.icon ? '' : undefined}
|
||||||
type="button"
|
type="button"
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
aria-expanded={open}
|
aria-expanded={open}
|
||||||
@@ -212,11 +214,11 @@ export default function CustomSelect({
|
|||||||
onMouseLeave={e => { if (!open) e.currentTarget.style.borderColor = 'var(--border-primary)' }}
|
onMouseLeave={e => { if (!open) e.currentTarget.style.borderColor = 'var(--border-primary)' }}
|
||||||
>
|
>
|
||||||
{selected?.icon && <span style={{ display: 'flex', flexShrink: 0 }}>{selected.icon}</span>}
|
{selected?.icon && <span style={{ display: 'flex', flexShrink: 0 }}>{selected.icon}</span>}
|
||||||
<span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', color: selected ? 'var(--text-primary)' : 'var(--text-faint)' }}>
|
<span data-select-label="" style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', color: selected ? 'var(--text-primary)' : 'var(--text-faint)' }}>
|
||||||
{selected ? selected.label : placeholder}
|
{selected ? selected.label : placeholder}
|
||||||
</span>
|
</span>
|
||||||
{selected?.badge && (
|
{selected?.badge && (
|
||||||
<span style={{
|
<span data-select-badge="" style={{
|
||||||
flexShrink: 0, fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, color: 'var(--text-muted)',
|
flexShrink: 0, fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, color: 'var(--text-muted)',
|
||||||
background: 'var(--bg-tertiary)', padding: '2px 7px', borderRadius: 999,
|
background: 'var(--bg-tertiary)', padding: '2px 7px', borderRadius: 999,
|
||||||
letterSpacing: '0.01em',
|
letterSpacing: '0.01em',
|
||||||
@@ -227,16 +229,17 @@ export default function CustomSelect({
|
|||||||
|
|
||||||
{/* Dropdown */}
|
{/* Dropdown */}
|
||||||
{menuOpen && createPortal(
|
{menuOpen && createPortal(
|
||||||
<div ref={dropRef} id={menuId} role="group" aria-label={ariaLabel || selected?.label || placeholder || undefined} onKeyDown={handleKeyDown} style={{
|
<div ref={dropRef} id={menuId} role="group" aria-label={ariaLabel || selected?.label || placeholder || undefined}
|
||||||
|
className={formRect ? 'm-root m-form-select-menu' : undefined} onKeyDown={handleKeyDown} style={{
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
...(anchored
|
...(anchored
|
||||||
? {
|
? {
|
||||||
...(anchored.flipped ? { bottom: anchored.bottom } : { top: anchored.top }),
|
...(anchored.flipped ? { bottom: anchored.bottom } : { top: anchored.top }),
|
||||||
left: anchored.left,
|
left: expandMenu && formRect ? Math.max(8, formRect.left + 18) : anchored.left,
|
||||||
// Never narrower than the trigger, and never past the right-hand edge of
|
// Never narrower than the trigger, and never past the right-hand edge of
|
||||||
// the window. The cap is read at render time rather than measured, and
|
// the window. The cap is read at render time rather than measured, and
|
||||||
// that is enough: every reason the anchor moved already re-renders this.
|
// that is enough: every reason the anchor moved already re-renders this.
|
||||||
...(!bounded && menuFit === 'content'
|
...(expandMenu ? { width: expandedWidth } : !bounded && menuFit === 'content'
|
||||||
? {
|
? {
|
||||||
minWidth: anchored.width,
|
minWidth: anchored.width,
|
||||||
width: 'max-content',
|
width: 'max-content',
|
||||||
@@ -310,6 +313,8 @@ export default function CustomSelect({
|
|||||||
<button
|
<button
|
||||||
key={option.value}
|
key={option.value}
|
||||||
type="button"
|
type="button"
|
||||||
|
data-select-option=""
|
||||||
|
aria-pressed={isSelected}
|
||||||
onClick={() => { if (!isSelected) selectionHaptic(); onChange(option.value); closeMenu() }}
|
onClick={() => { if (!isSelected) selectionHaptic(); onChange(option.value); closeMenu() }}
|
||||||
style={{
|
style={{
|
||||||
width: '100%', display: 'flex', alignItems: 'center', gap: 8,
|
width: '100%', display: 'flex', alignItems: 'center', gap: 8,
|
||||||
@@ -322,9 +327,9 @@ export default function CustomSelect({
|
|||||||
onMouseLeave={e => e.currentTarget.style.background = isSelected ? 'var(--bg-hover)' : 'transparent'}
|
onMouseLeave={e => e.currentTarget.style.background = isSelected ? 'var(--bg-hover)' : 'transparent'}
|
||||||
>
|
>
|
||||||
{option.icon && <span style={{ display: 'flex', flexShrink: 0 }}>{option.icon}</span>}
|
{option.icon && <span style={{ display: 'flex', flexShrink: 0 }}>{option.icon}</span>}
|
||||||
<span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{option.label}</span>
|
<span data-select-label="" style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{option.label}</span>
|
||||||
{option.badge && (
|
{option.badge && (
|
||||||
<span style={{
|
<span data-select-badge="" style={{
|
||||||
flexShrink: 0, fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, color: 'var(--text-muted)',
|
flexShrink: 0, fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, color: 'var(--text-muted)',
|
||||||
background: 'var(--bg-tertiary)', padding: '2px 7px', borderRadius: 999,
|
background: 'var(--bg-tertiary)', padding: '2px 7px', borderRadius: 999,
|
||||||
letterSpacing: '0.01em',
|
letterSpacing: '0.01em',
|
||||||
|
|||||||
@@ -550,6 +550,12 @@ describe('CustomTimePicker honours the configured time format', () => {
|
|||||||
expect(screen.getByRole('textbox')).toHaveProperty('value', '14:30');
|
expect(screen.getByRole('textbox')).toHaveProperty('value', '14:30');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('keeps an explicitly empty placeholder in 12h mode', () => {
|
||||||
|
use('12h');
|
||||||
|
render(<CustomTimePicker value="" placeholder="" onChange={onChange} />);
|
||||||
|
expect(screen.getByRole('textbox')).toHaveProperty('placeholder', '');
|
||||||
|
});
|
||||||
|
|
||||||
// Display alone is not enough: a value stored as "3:00 PM" stays that way in the
|
// Display alone is not enough: a value stored as "3:00 PM" stays that way in the
|
||||||
// database until someone edits the field. The picker hands the parsed HH:MM back to
|
// database until someone edits the field. The picker hands the parsed HH:MM back to
|
||||||
// the form instead, so the next save writes a clean value.
|
// the form instead, so the next save writes a clean value.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Clock } from 'lucide-react'
|
|||||||
import { useSettingsStore } from '../../store/settingsStore'
|
import { useSettingsStore } from '../../store/settingsStore'
|
||||||
import { formatClockTime, parseMeridiemTime } from '../../utils/formatters'
|
import { formatClockTime, parseMeridiemTime } from '../../utils/formatters'
|
||||||
import { useAnchoredPosition } from '../../hooks/useAnchoredPosition'
|
import { useAnchoredPosition } from '../../hooks/useAnchoredPosition'
|
||||||
|
import { useOverlay } from '../../hooks/overlayStack'
|
||||||
import { TimeSpinnerColumn } from './TimeSpinnerColumn'
|
import { TimeSpinnerColumn } from './TimeSpinnerColumn'
|
||||||
import { spinnerButtonStyle } from './timeSpinnerStyle'
|
import { spinnerButtonStyle } from './timeSpinnerStyle'
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ interface CustomTimePickerProps {
|
|||||||
export default function CustomTimePicker({ value, onChange, placeholder = '00:00', style = {}, disabled = false, ...aria }: CustomTimePickerProps) {
|
export default function CustomTimePicker({ value, onChange, placeholder = '00:00', style = {}, disabled = false, ...aria }: CustomTimePickerProps) {
|
||||||
const is12h = useSettingsStore(s => s.settings.time_format) === '12h'
|
const is12h = useSettingsStore(s => s.settings.time_format) === '12h'
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
useOverlay(open, () => setOpen(false), true)
|
||||||
const [inputFocused, setInputFocused] = useState(false)
|
const [inputFocused, setInputFocused] = useState(false)
|
||||||
const ref = useRef<HTMLDivElement>(null)
|
const ref = useRef<HTMLDivElement>(null)
|
||||||
const dropRef = useRef<HTMLDivElement>(null)
|
const dropRef = useRef<HTMLDivElement>(null)
|
||||||
@@ -142,7 +144,7 @@ export default function CustomTimePicker({ value, onChange, placeholder = '00:00
|
|||||||
onChange={handleInput}
|
onChange={handleInput}
|
||||||
onFocus={() => setInputFocused(true)}
|
onFocus={() => setInputFocused(true)}
|
||||||
onBlur={() => { setInputFocused(false); handleBlur() }}
|
onBlur={() => { setInputFocused(false); handleBlur() }}
|
||||||
placeholder={is12h ? '2:30 PM' : placeholder}
|
placeholder={is12h && placeholder ? '2:30 PM' : placeholder}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
style={{
|
style={{
|
||||||
flex: 1, border: 'none', outline: 'none', background: 'transparent',
|
flex: 1, border: 'none', outline: 'none', background: 'transparent',
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ interface PlaceRatingProps {
|
|||||||
size?: number
|
size?: number
|
||||||
/** Hide the voter avatar strip (compact mobile rows). */
|
/** Hide the voter avatar strip (compact mobile rows). */
|
||||||
compact?: boolean
|
compact?: boolean
|
||||||
|
hideEmptyLabel?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +91,7 @@ interface PlaceRatingProps {
|
|||||||
* voter avatars. Hovering reveals a custom tooltip listing every voter with
|
* voter avatars. Hovering reveals a custom tooltip listing every voter with
|
||||||
* their stars.
|
* their stars.
|
||||||
*/
|
*/
|
||||||
export default function PlaceRating({ ratings, ratingAvg, onRate, size = 16, compact = false }: PlaceRatingProps) {
|
export default function PlaceRating({ ratings, ratingAvg, onRate, size = 16, compact = false, hideEmptyLabel = false }: PlaceRatingProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const currentUserId = useAuthStore(s => s.user?.id)
|
const currentUserId = useAuthStore(s => s.user?.id)
|
||||||
const [tip, setTip] = useState<{ top: number; left: number } | null>(null)
|
const [tip, setTip] = useState<{ top: number; left: number } | null>(null)
|
||||||
@@ -114,7 +115,7 @@ export default function PlaceRating({ ratings, ratingAvg, onRate, size = 16, com
|
|||||||
<span style={{ fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600, color: 'var(--text-secondary)', fontVariantNumeric: 'tabular-nums' }}>
|
<span style={{ fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 600, color: 'var(--text-secondary)', fontVariantNumeric: 'tabular-nums' }}>
|
||||||
{(Math.round(avg * 10) / 10).toLocaleString()} <span style={{ fontWeight: 400, color: 'var(--text-faint)' }}>({ratings.length})</span>
|
{(Math.round(avg * 10) / 10).toLocaleString()} <span style={{ fontWeight: 400, color: 'var(--text-faint)' }}>({ratings.length})</span>
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : !hideEmptyLabel && (
|
||||||
<span style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', color: 'var(--text-faint)' }}>{t('places.notRated')}</span>
|
<span style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', color: 'var(--text-faint)' }}>{t('places.notRated')}</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useLayoutEffect, useRef, useSyncExternalStore } from 'react';
|
import { useCallback, useEffect, useLayoutEffect, useRef, useSyncExternalStore } from 'react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The overlays open on screen, newest last, so a way back closes the one on
|
* The overlays open on screen, newest last, so a way back closes the one on
|
||||||
@@ -38,22 +38,35 @@ export function useHasOpenOverlay(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Registers an overlay while `open`, with the way it closes. */
|
/** Registers an overlay while `open`, with the way it closes. */
|
||||||
export function useOverlay(open: boolean, close: Close): void {
|
export function useOverlay(open: boolean, close: Close, dismissOnEscape = false): () => boolean {
|
||||||
const closeRef = useRef(close);
|
const closeRef = useRef(close);
|
||||||
|
const entryId = useRef<number | null>(null);
|
||||||
|
const isTop = useCallback(() => stack[stack.length - 1]?.id === entryId.current, []);
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
closeRef.current = close;
|
closeRef.current = close;
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
const entry = { id: nextId++, close: () => closeRef.current() };
|
const entry = { id: nextId++, close: () => closeRef.current() };
|
||||||
|
entryId.current = entry.id;
|
||||||
stack.push(entry);
|
stack.push(entry);
|
||||||
changed();
|
changed();
|
||||||
|
const onKey = (event: KeyboardEvent) => {
|
||||||
|
if (event.key !== 'Escape' || event.defaultPrevented || !isTop()) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
entry.close();
|
||||||
|
};
|
||||||
|
if (dismissOnEscape) window.addEventListener('keydown', onKey, true);
|
||||||
return () => {
|
return () => {
|
||||||
|
if (dismissOnEscape) window.removeEventListener('keydown', onKey, true);
|
||||||
const i = stack.findIndex((e) => e.id === entry.id);
|
const i = stack.findIndex((e) => e.id === entry.id);
|
||||||
if (i >= 0) stack.splice(i, 1);
|
if (i >= 0) stack.splice(i, 1);
|
||||||
|
entryId.current = null;
|
||||||
changed();
|
changed();
|
||||||
};
|
};
|
||||||
}, [open]);
|
}, [open, dismissOnEscape, isTop]);
|
||||||
|
return isTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test helper. */
|
/** Test helper. */
|
||||||
@@ -23,10 +23,15 @@ const NO_VIAS: Record<number, RoadtripVia[]> = {}
|
|||||||
* `roadtripVias` are the road trip's vias by day: a road picked there is the road this
|
* `roadtripVias` are the road trip's vias by day: a road picked there is the road this
|
||||||
* day drives too (#2580). Absent, or empty while the road trip addon is off.
|
* day drives too (#2580). Absent, or empty while the road trip addon is off.
|
||||||
*/
|
*/
|
||||||
export function useRouteCalculation(tripStore: Pick<TripStoreState, 'assignments'> & { roadtripVias?: Record<number, RoadtripVia[]>; tourStageStops?: DayRouteInputs['tourStageStops'] }, selectedDayId: number | null, enabled: boolean = true, profile: RouteProfileKey = 'driving', accommodations: Accommodation[] = NO_ACCOMMODATIONS) {
|
export function useRouteCalculation(tripStore: Pick<TripStoreState, 'assignments'> & {
|
||||||
|
roadtripVias?: Record<number, RoadtripVia[]>
|
||||||
|
tourStageStops?: DayRouteInputs['tourStageStops']
|
||||||
|
includeLocatedBookings?: boolean
|
||||||
|
}, selectedDayId: number | null, enabled: boolean = true, profile: RouteProfileKey = 'driving', accommodations: Accommodation[] = NO_ACCOMMODATIONS) {
|
||||||
const viasByDay = tripStore.roadtripVias ?? NO_VIAS
|
const viasByDay = tripStore.roadtripVias ?? NO_VIAS
|
||||||
// MDT-02: a day holding one stage of a multi-day tour routes to that stage.
|
// MDT-02: a day holding one stage of a multi-day tour routes to that stage.
|
||||||
const tourStageStops = tripStore.tourStageStops
|
const tourStageStops = tripStore.tourStageStops
|
||||||
|
const includeLocatedBookings = tripStore.includeLocatedBookings
|
||||||
const [route, setRoute] = useState<[number, number][][] | null>(null)
|
const [route, setRoute] = useState<[number, number][][] | null>(null)
|
||||||
const [routeInfo, setRouteInfo] = useState<RouteResult | null>(null)
|
const [routeInfo, setRouteInfo] = useState<RouteResult | null>(null)
|
||||||
const [routeSegments, setRouteSegments] = useState<RouteSegment[]>([])
|
const [routeSegments, setRouteSegments] = useState<RouteSegment[]>([])
|
||||||
@@ -71,6 +76,7 @@ export function useRouteCalculation(tripStore: Pick<TripStoreState, 'assignments
|
|||||||
toursEnabled,
|
toursEnabled,
|
||||||
places,
|
places,
|
||||||
tourStageStops,
|
tourStageStops,
|
||||||
|
includeLocatedBookings,
|
||||||
})
|
})
|
||||||
const day = allDays.find(d => d.id === dayId)
|
const day = allDays.find(d => d.id === dayId)
|
||||||
// Anchors count the stored list, the hidden lodging and service rows included.
|
// Anchors count the stored list, the hidden lodging and service rows included.
|
||||||
@@ -159,23 +165,23 @@ export function useRouteCalculation(tripStore: Pick<TripStoreState, 'assignments
|
|||||||
// Aborted (day changed) — newer call owns the state. Anything else: keep straight lines.
|
// Aborted (day changed) — newer call owns the state. Anything else: keep straight lines.
|
||||||
if (!(err instanceof Error) || err.name !== 'AbortError') { setRouteSegments([]); setRouteVias([]) }
|
if (!(err instanceof Error) || err.name !== 'AbortError') { setRouteSegments([]); setRouteVias([]) }
|
||||||
}
|
}
|
||||||
}, [enabled, profile, accommodations, optimizeFromAccommodation, distanceUnit, selectedDayDefaultMode, mirrorServiceStops, toursEnabled, places, viasByDay, tourStageStops])
|
}, [enabled, profile, accommodations, optimizeFromAccommodation, distanceUnit, selectedDayDefaultMode, mirrorServiceStops, toursEnabled, places, viasByDay, tourStageStops, includeLocatedBookings])
|
||||||
|
|
||||||
// Stable signature for transport reservations on the selected day — changes when a transport
|
// Stable signature for transport reservations on the selected day — changes when a transport
|
||||||
// is added, removed, or repositioned, ensuring route recalc fires even on transport-only reorders.
|
// is added, removed, or repositioned, ensuring route recalc fires even on transport-only reorders.
|
||||||
const transportSignature = useMemo(() => {
|
const transportSignature = useMemo(() => {
|
||||||
if (!selectedDayId) return ''
|
if (!selectedDayId) return ''
|
||||||
return reservationsForSignature
|
return reservationsForSignature
|
||||||
.filter(r => TRANSPORT_TYPES.includes(r.type))
|
.filter(r => TRANSPORT_TYPES.includes(r.type) || (includeLocatedBookings && r.place_id != null))
|
||||||
.map(r => {
|
.map(r => {
|
||||||
const pos = r.day_positions?.[selectedDayId] ?? r.day_positions?.[String(selectedDayId)] ?? r.day_plan_position
|
const pos = r.day_positions?.[selectedDayId] ?? r.day_positions?.[String(selectedDayId)] ?? r.day_plan_position
|
||||||
// Include endpoints so adding/moving a departure/arrival location re-routes.
|
// Include endpoints so adding/moving a departure/arrival location re-routes.
|
||||||
const eps = (r.endpoints || []).map(e => `${e.role}@${e.lat ?? ''},${e.lng ?? ''}`).join(';')
|
const eps = (r.endpoints || []).map(e => `${e.role}@${e.lat ?? ''},${e.lng ?? ''}`).join(';')
|
||||||
return `${r.id}:${r.day_id ?? ''}:${r.end_day_id ?? ''}:${r.reservation_time ?? ''}:${pos ?? ''}:${eps}`
|
return `${r.id}:${r.type}:${r.place_id ?? ''}:${r.assignment_id ?? ''}:${r.day_id ?? ''}:${r.end_day_id ?? ''}:${r.reservation_time ?? ''}:${r.reservation_end_time ?? ''}:${pos ?? ''}:${eps}`
|
||||||
})
|
})
|
||||||
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
||||||
.join('|')
|
.join('|')
|
||||||
}, [reservationsForSignature, selectedDayId])
|
}, [reservationsForSignature, selectedDayId, includeLocatedBookings])
|
||||||
|
|
||||||
// Recalculate when assignments or transport positions for the SELECTED day change
|
// Recalculate when assignments or transport positions for the SELECTED day change
|
||||||
const selectedDayAssignments = selectedDayId ? tripStore.assignments?.[String(selectedDayId)] : null
|
const selectedDayAssignments = selectedDayId ? tripStore.assignments?.[String(selectedDayId)] : null
|
||||||
@@ -183,7 +189,7 @@ export function useRouteCalculation(tripStore: Pick<TripStoreState, 'assignments
|
|||||||
if (!selectedDayId) { setRoute(null); setRouteWalking([]); setRouteSegments([]); setRouteVias([]); return }
|
if (!selectedDayId) { setRoute(null); setRouteWalking([]); setRouteSegments([]); setRouteVias([]); return }
|
||||||
updateRouteForDay(selectedDayId)
|
updateRouteForDay(selectedDayId)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [selectedDayId, selectedDayAssignments, transportSignature, enabled, profile, accommodations, optimizeFromAccommodation, distanceUnit, selectedDayDefaultMode, mirrorServiceStops, toursEnabled, places, viaKey, tourStageStops])
|
}, [selectedDayId, selectedDayAssignments, transportSignature, enabled, profile, accommodations, optimizeFromAccommodation, distanceUnit, selectedDayDefaultMode, mirrorServiceStops, toursEnabled, places, viaKey, tourStageStops, includeLocatedBookings])
|
||||||
|
|
||||||
return { route, routeWalking, routeSegments, routeVias, routeInfo, setRoute, setRouteInfo, updateRouteForDay }
|
return { route, routeWalking, routeSegments, routeVias, routeInfo, setRoute, setRouteInfo, updateRouteForDay }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import MMailInboxHost from './screens/mail/MMailInboxHost'
|
|||||||
import { useNativeCapabilities } from '../native/capabilities'
|
import { useNativeCapabilities } from '../native/capabilities'
|
||||||
import { isNativeIos } from '../native/platform'
|
import { isNativeIos } from '../native/platform'
|
||||||
import { useWindowFold } from '../native/windowFold'
|
import { useWindowFold } from '../native/windowFold'
|
||||||
|
import './mobileMascot.css'
|
||||||
import './mobile.css'
|
import './mobile.css'
|
||||||
|
import './mobileSelect.css'
|
||||||
|
|
||||||
interface MobileShellProps {
|
interface MobileShellProps {
|
||||||
isPhone: boolean
|
isPhone: boolean
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ interface MBadgeProps {
|
|||||||
* look, for the single figure a surface is about, and never inside something tappable:
|
* look, for the single figure a surface is about, and never inside something tappable:
|
||||||
* a filled pill in a button reads as a second control sitting in the first.
|
* a filled pill in a button reads as a second control sitting in the first.
|
||||||
*/
|
*/
|
||||||
tone?: 'neutral' | 'strong'
|
tone?: 'neutral' | 'strong' | 'glass'
|
||||||
/** `xs` is 18px, for a second line under a title. `sm` is 22px, for a 34px pill. */
|
/** `xs` is 18px, for a second line under a title. `sm` is 22px, for a 34px pill. */
|
||||||
size?: 'xs' | 'sm'
|
size?: 'xs' | 'sm'
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +55,9 @@ export default function MBadge({
|
|||||||
} ${caps ? 'uppercase tracking-[.07em]' : ''} ${
|
} ${caps ? 'uppercase tracking-[.07em]' : ''} ${
|
||||||
tone === 'strong'
|
tone === 'strong'
|
||||||
? 'bg-m-act text-m-actfg'
|
? 'bg-m-act text-m-actfg'
|
||||||
: 'border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] text-m-ink'
|
: tone === 'glass'
|
||||||
|
? 'm-glass-badge border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] text-m-ink'
|
||||||
|
: 'border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] text-m-ink'
|
||||||
} ${className}`}
|
} ${className}`}
|
||||||
>
|
>
|
||||||
{/* The icon only repeats what the label says, so it stays out of the name. */}
|
{/* The icon only repeats what the label says, so it stays out of the name. */}
|
||||||
|
|||||||
@@ -2,20 +2,18 @@ import { useEffect, useState } from 'react'
|
|||||||
import { useNavigate, useLocation, matchPath } from 'react-router'
|
import { useNavigate, useLocation, matchPath } from 'react-router'
|
||||||
import { useSettingsStore } from '../../store/settingsStore'
|
import { useSettingsStore } from '../../store/settingsStore'
|
||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
import { ChevronRight, MoreHorizontal, Plus, Search, Upload } from 'lucide-react'
|
import { MoreHorizontal, Plus, Search, Upload } from 'lucide-react'
|
||||||
import { normalizeAppearance } from '@trek/shared'
|
import { normalizeAppearance } from '@trek/shared'
|
||||||
import { useDockNavItems, splitMobileNav, ASSISTANT_NAV_ID, type NavItemDef } from '../../components/Layout/navItems'
|
import { useDockNavItems, splitMobileNav, ASSISTANT_NAV_ID, type NavItemDef } from '../../components/Layout/navItems'
|
||||||
import { isNavItemActive, useCreateAction } from '../../components/Layout/useCreateAction'
|
import { isNavItemActive, useCreateAction } from '../../components/Layout/useCreateAction'
|
||||||
import MFab from './MFab'
|
import MFab from './MFab'
|
||||||
import { useAssistantHomeLauncher } from '../../components/Assistant/useAssistantHome'
|
import { useAssistantHomeLauncher } from '../../components/Assistant/useAssistantHome'
|
||||||
import MDockScrim from './MDockScrim'
|
import MDockScrim from './MDockScrim'
|
||||||
|
import MMenuRow from './MMenuRow'
|
||||||
|
import MSheet from './MSheet'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Floating glass dock of the mobile shell. Same tab/gating/"+" logic as the
|
* Labelled destination dock with a persistent slot for the screen's primary action.
|
||||||
* legacy BottomNav (addons, ?create= contract), redesigned as the demo's icon
|
|
||||||
* dock: 42px circles, active on the --m-act pill, Journey/Collections and page
|
|
||||||
* plugins behind the "More" popover, and a context FAB in the middle (search
|
|
||||||
* on the atlas, disabled logo slot on settings/admin).
|
|
||||||
*/
|
*/
|
||||||
export default function MBottomNav() {
|
export default function MBottomNav() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -33,8 +31,7 @@ export default function MBottomNav() {
|
|||||||
useEffect(() => setMoreOpen(false), [location.pathname])
|
useEffect(() => setMoreOpen(false), [location.pathname])
|
||||||
|
|
||||||
// The dock split + order is user-configurable (Settings → Appearance → Mobile);
|
// The dock split + order is user-configurable (Settings → Appearance → Mobile);
|
||||||
// an un-customised account falls back to the built-in Dashboard + vacay/atlas
|
// an un-customised account uses the default addon priority.
|
||||||
// dock with everything else under "More".
|
|
||||||
const navItems = useDockNavItems()
|
const navItems = useDockNavItems()
|
||||||
const appearance = useSettingsStore(s => s.settings.appearance)
|
const appearance = useSettingsStore(s => s.settings.appearance)
|
||||||
const split = splitMobileNav(navItems, normalizeAppearance(appearance).mobileNav)
|
const split = splitMobileNav(navItems, normalizeAppearance(appearance).mobileNav)
|
||||||
@@ -51,11 +48,9 @@ export default function MBottomNav() {
|
|||||||
const moreActive = moreItems.some(isActive)
|
const moreActive = moreItems.some(isActive)
|
||||||
const hasMore = moreItems.length > 0
|
const hasMore = moreItems.length > 0
|
||||||
|
|
||||||
// The FAB gives way to a decorative logo slot on screens without an add
|
const logoSlot = ['/settings', '/admin'].some(path => location.pathname.startsWith(path))
|
||||||
// action (settings/admin, demo Z. 1372/1429).
|
|
||||||
const logoSlot = location.pathname.startsWith('/settings') || location.pathname.startsWith('/admin')
|
|
||||||
const searchFab = location.pathname.startsWith('/atlas')
|
const searchFab = location.pathname.startsWith('/atlas')
|
||||||
// /vacay owns the centre slot itself: MVacay draws its year/edit toggle into
|
// /vacay owns the centre slot itself: MVacay draws its jump to today into
|
||||||
// exactly this 56px circle. The dock keeps the geometry but stays empty there,
|
// exactly this 56px circle. The dock keeps the geometry but stays empty there,
|
||||||
// so the generic "+" can never sit underneath as a second, different action:
|
// so the generic "+" can never sit underneath as a second, different action:
|
||||||
// not while the lazy screen chunk loads, and not while its data loads (#1811).
|
// not while the lazy screen chunk loads, and not while its data loads (#1811).
|
||||||
@@ -68,22 +63,14 @@ export default function MBottomNav() {
|
|||||||
const left = dockItems.slice(0, splitAt)
|
const left = dockItems.slice(0, splitAt)
|
||||||
const right = dockItems.slice(splitAt)
|
const right = dockItems.slice(splitAt)
|
||||||
|
|
||||||
const circleCls = (active: boolean) =>
|
|
||||||
`flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full ${
|
|
||||||
active ? 'bg-m-act text-m-actfg' : 'text-m-muted'
|
|
||||||
}`
|
|
||||||
// More stands for whichever of its screens is on show, so it is marked as a
|
|
||||||
// ring: a filled circle beside the filled "+" read as two of the same action.
|
|
||||||
const moreCls = (active: boolean) =>
|
|
||||||
`flex h-[42px] w-[42px] flex-none items-center justify-center rounded-full ${
|
|
||||||
active ? 'bg-[color:var(--m-ic)] text-m-ink ring-[1.5px] ring-inset ring-[color:var(--m-act)]' : 'text-m-muted'
|
|
||||||
}`
|
|
||||||
// A map runs to the screen's edge on purpose; everything else fades out under the dock.
|
// A map runs to the screen's edge on purpose; everything else fades out under the dock.
|
||||||
const overMap = location.pathname.startsWith('/atlas') || matchPath('/journey/:id', location.pathname) !== null
|
const overMap = location.pathname.startsWith('/atlas') || matchPath('/journey/:id', location.pathname) !== null
|
||||||
|
|
||||||
const renderItem = (item: NavItemDef) => {
|
const renderItem = (item: NavItemDef) => {
|
||||||
const { id, label, icon: Icon } = item
|
const { id, label, icon: Icon } = item
|
||||||
const active = isActive(item)
|
const active = isActive(item)
|
||||||
|
const shortLabel = id === 'dashboard' ? t('dashboard.mobile.trips')
|
||||||
|
: id === 'collections' ? t('dashboard.mobile.places') : label
|
||||||
// Fixed sizes per slot (demo): the dashboard grid is 18/2.1, every other
|
// Fixed sizes per slot (demo): the dashboard grid is 18/2.1, every other
|
||||||
// slot 21/1.9 — independent of the active state.
|
// slot 21/1.9 — independent of the active state.
|
||||||
const dash = id === 'dashboard'
|
const dash = id === 'dashboard'
|
||||||
@@ -94,43 +81,35 @@ export default function MBottomNav() {
|
|||||||
onClick={() => open(item)}
|
onClick={() => open(item)}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
aria-current={active ? 'page' : undefined}
|
aria-current={active ? 'page' : undefined}
|
||||||
className={circleCls(active)}
|
className="m-dock-item"
|
||||||
>
|
>
|
||||||
<Icon size={dash ? 18 : 21} strokeWidth={dash ? 2.1 : 1.9} />
|
<span className="m-dock-symbol"><Icon size={dash ? 18 : 21} strokeWidth={dash ? 2.1 : 1.9} /></span>
|
||||||
|
<span className={`m-dock-label${dash ? ' capitalize' : ''}`}>{shortLabel}</span>
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{moreOpen && (
|
{hasMore && (
|
||||||
// Invisible scrim (the popover sits on the UI without dimming it).
|
<MSheet open={moreOpen} covered={!moreOpen} onClose={() => setMoreOpen(false)} variant="bottom" dimTransparent ariaLabel={t('mobileNav.more')}>
|
||||||
<div className="fixed inset-0 z-[60]" role="presentation" onClick={() => setMoreOpen(false)}>
|
<div className="min-h-0 divide-y divide-[color:var(--m-rowbr)] overflow-y-auto overscroll-contain px-2 py-2">
|
||||||
<div
|
{moreItems.map(item => (
|
||||||
className="absolute inset-x-4 flex flex-col gap-2 rounded-[26px] border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] p-[10px] shadow-[0_-8px_40px_-14px_rgba(0,0,0,.45)] backdrop-blur-[30px] backdrop-saturate-[1.8] bottom-[calc(env(safe-area-inset-bottom,0px)+86px)]"
|
<MMenuRow
|
||||||
role="presentation"
|
|
||||||
onClick={e => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
{moreItems.map((item) => (
|
|
||||||
<button
|
|
||||||
key={item.id}
|
key={item.id}
|
||||||
type="button"
|
icon={item.icon}
|
||||||
|
label={item.label}
|
||||||
|
current={isActive(item)}
|
||||||
|
disabled={!moreOpen}
|
||||||
onClick={() => { setMoreOpen(false); open(item) }}
|
onClick={() => { setMoreOpen(false); open(item) }}
|
||||||
className="flex items-center gap-[13px] rounded-[18px] bg-[color:var(--m-ic)] px-4 py-[14px] text-start"
|
/>
|
||||||
>
|
|
||||||
<span className="flex h-10 w-10 flex-none items-center justify-center rounded-xl bg-[color:var(--m-ic)] text-m-ink">
|
|
||||||
<item.icon size={20} strokeWidth={2} />
|
|
||||||
</span>
|
|
||||||
<span className="block min-w-0 flex-1 truncate text-[0.9375rem] font-extrabold text-m-ink">{item.label}</span>
|
|
||||||
<ChevronRight size={17} strokeWidth={2} className="flex-none text-m-faint" />
|
|
||||||
</button>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</MSheet>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!overMap && <MDockScrim />}
|
{!overMap && <MDockScrim />}
|
||||||
<nav className="m-dock-vt fixed inset-x-4 z-40 flex h-[62px] items-center rounded-[31px] border border-[color:var(--m-gbr)] bg-[color:var(--m-dock)] px-3 shadow-[0_16px_44px_-14px_rgba(0,0,0,.35)] backdrop-blur-[30px] backdrop-saturate-[1.4] bottom-[calc(env(safe-area-inset-bottom,0px)+12px)]">
|
<nav aria-label={t('mobileNav.navigation')} className="m-dock-vt m-labelled-dock fixed inset-x-4 z-40 flex h-[62px] items-center rounded-[24px] border border-[color:var(--m-gbr)] bg-[color:var(--m-dock)] px-2 backdrop-blur-[24px] bottom-[calc(env(safe-area-inset-bottom,0px)+12px)]">
|
||||||
<div className="flex min-w-0 flex-1 items-center justify-around">{left.map(renderItem)}</div>
|
<div className="flex min-w-0 flex-1 items-center justify-around">{left.map(renderItem)}</div>
|
||||||
|
|
||||||
{logoSlot ? (
|
{logoSlot ? (
|
||||||
@@ -160,10 +139,12 @@ export default function MBottomNav() {
|
|||||||
onClick={() => setMoreOpen(v => !v)}
|
onClick={() => setMoreOpen(v => !v)}
|
||||||
aria-label={t('mobileNav.more')}
|
aria-label={t('mobileNav.more')}
|
||||||
aria-expanded={moreOpen}
|
aria-expanded={moreOpen}
|
||||||
|
aria-haspopup="dialog"
|
||||||
aria-current={moreActive ? 'page' : undefined}
|
aria-current={moreActive ? 'page' : undefined}
|
||||||
className={moreCls(moreActive)}
|
className="m-dock-item"
|
||||||
>
|
>
|
||||||
<MoreHorizontal size={21} strokeWidth={1.9} />
|
<span className="m-dock-symbol"><MoreHorizontal size={21} strokeWidth={1.9} /></span>
|
||||||
|
<span className="m-dock-label">{t('mobileNav.more')}</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
import { X, type LucideIcon } from 'lucide-react';
|
||||||
import type { ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
|
import { useTranslation } from '../../i18n';
|
||||||
|
import MIconBtn from './MIconBtn';
|
||||||
import MSheet from './MSheet';
|
import MSheet from './MSheet';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The menu a long press on a card opens (useLongPress): what it is about on
|
* A labelled list of context actions for cards and page controls.
|
||||||
* top, then its actions, the destructive one in red. The same actions the
|
|
||||||
* card's own buttons offer, so this is a second way, never the only one.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface ContextAction {
|
interface ContextAction {
|
||||||
@@ -12,41 +13,63 @@ interface ContextAction {
|
|||||||
label: string;
|
label: string;
|
||||||
icon: ReactElement;
|
icon: ReactElement;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
|
pressed?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MContextMenuProps {
|
interface MContextMenuProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
|
icon?: LucideIcon;
|
||||||
actions: ContextAction[];
|
actions: ContextAction[];
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MContextMenu({ open, title, actions, onClose }: MContextMenuProps) {
|
export default function MContextMenu({ open, title, icon: Icon, actions, onClose }: MContextMenuProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<MSheet open={open} onClose={onClose} variant="bottom" wideWidth="compact" ariaLabel={title}>
|
<MSheet open={open} covered={!open} onClose={onClose} variant="bottom" wideWidth="compact" ariaLabel={title}>
|
||||||
<div className="min-h-0 overflow-y-auto overscroll-contain p-[10px]">
|
<header className="flex flex-none items-center gap-3 px-[18px] pb-3 pt-4">
|
||||||
<div dir="auto" className="truncate px-[10px] pb-2 pt-1 text-caption font-semibold text-m-muted">
|
{Icon && (
|
||||||
|
<span className="grid size-10 flex-none place-items-center rounded-[13px] bg-m-ic" aria-hidden>
|
||||||
|
<Icon size={19} strokeWidth={1.8} />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<h2 dir="auto" className="line-clamp-2 min-w-0 flex-1 break-words text-subtitle font-bold">
|
||||||
{title}
|
{title}
|
||||||
|
</h2>
|
||||||
|
<MIconBtn ariaLabel={t('common.close')} onClick={onClose} variant="neutral" size={36}>
|
||||||
|
<X size={16} aria-hidden />
|
||||||
|
</MIconBtn>
|
||||||
|
</header>
|
||||||
|
<div className="min-h-0 overflow-y-auto overscroll-contain px-[18px] pb-4">
|
||||||
|
<div className="divide-y divide-m-rowbr overflow-hidden rounded-2xl bg-m-ic">
|
||||||
|
{actions.map((action) => {
|
||||||
|
const danger = action.key === 'delete';
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={action.key}
|
||||||
|
type="button"
|
||||||
|
disabled={!open}
|
||||||
|
aria-pressed={action.pressed}
|
||||||
|
onClick={() => {
|
||||||
|
onClose();
|
||||||
|
action.onClick();
|
||||||
|
}}
|
||||||
|
className={`flex min-h-12 w-full items-center gap-3 px-3 py-2 text-start text-control font-semibold active:bg-m-rowbr ${
|
||||||
|
danger ? 'text-[color:var(--m-st-danger)]' : 'text-m-ink'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={`grid size-8 flex-none place-items-center rounded-lg bg-m-sheetop ${danger ? '' : 'text-m-muted'}`}
|
||||||
|
aria-hidden
|
||||||
|
>
|
||||||
|
{action.icon}
|
||||||
|
</span>
|
||||||
|
<span className="min-w-0 flex-1 break-words">{action.label}</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
{actions.map((action) => {
|
|
||||||
const danger = action.key === 'delete';
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={action.key}
|
|
||||||
type="button"
|
|
||||||
onClick={() => {
|
|
||||||
onClose();
|
|
||||||
action.onClick();
|
|
||||||
}}
|
|
||||||
className={`flex w-full items-center gap-[11px] rounded-xl px-[10px] py-[11px] text-start text-body font-semibold active:bg-[color:var(--m-ic)] ${
|
|
||||||
danger ? 'text-[color:var(--m-st-danger)]' : 'text-m-ink'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<span className={`flex flex-none ${danger ? '' : 'text-m-muted'}`}>{action.icon}</span>
|
|
||||||
<span className="min-w-0 flex-1 truncate">{action.label}</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
</MSheet>
|
</MSheet>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { findClip, mascot3dEnabled } from './trek3d/mascotClips';
|
|||||||
*
|
*
|
||||||
* Body motion (`.trek-bounce--<scene>`) and each prop animate independently, so
|
* Body motion (`.trek-bounce--<scene>`) and each prop animate independently, so
|
||||||
* the mascot can react to a prop without the prop moving with it. Choreography
|
* the mascot can react to a prop without the prop moving with it. Choreography
|
||||||
* lives in mobile.css (.trek-*). Poking (tap) remounts the svg to replay the
|
* lives in mobileMascot.css (.trek-*). Poking (tap) remounts the svg to replay the
|
||||||
* entrance pop-in as a bounce.
|
* entrance pop-in as a bounce.
|
||||||
*/
|
*/
|
||||||
export type TrekScene =
|
export type TrekScene =
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
import { closeTopOverlay, hasOpenOverlay } from '../../hooks/overlayStack';
|
||||||
import { tickHaptic } from '../../native/haptics';
|
import { tickHaptic } from '../../native/haptics';
|
||||||
import { closeTopOverlay, hasOpenOverlay } from '../overlayStack';
|
|
||||||
import MEdgeBack from './MEdgeBack';
|
import MEdgeBack from './MEdgeBack';
|
||||||
|
|
||||||
vi.mock('../overlayStack', () => ({ closeTopOverlay: vi.fn(), hasOpenOverlay: vi.fn(() => false) }));
|
vi.mock('../../hooks/overlayStack', () => ({ closeTopOverlay: vi.fn(), hasOpenOverlay: vi.fn(() => false) }));
|
||||||
vi.mock('../../native/haptics', () => ({ tickHaptic: vi.fn() }));
|
vi.mock('../../native/haptics', () => ({ tickHaptic: vi.fn() }));
|
||||||
|
|
||||||
function Host({ enabled = true }: { enabled?: boolean }) {
|
function Host({ enabled = true }: { enabled?: boolean }) {
|
||||||
@@ -33,11 +33,40 @@ beforeEach(() => {
|
|||||||
Object.defineProperty(window, 'innerWidth', { configurable: true, value: 400 });
|
Object.defineProperty(window, 'innerWidth', { configurable: true, value: 400 });
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
document.documentElement.removeAttribute('dir');
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('MEdgeBack', () => {
|
describe('MEdgeBack', () => {
|
||||||
|
it('mirrors the swipe from the right edge in a right-to-left interface', () => {
|
||||||
|
document.documentElement.dir = 'rtl';
|
||||||
|
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
||||||
|
const { getByTestId } = render(<Host />);
|
||||||
|
|
||||||
|
touch('touchstart', 395, 300, 0);
|
||||||
|
touch('touchmove', 220, 300, 100);
|
||||||
|
expect(getByTestId('page').style.transform).toBe('translateX(-175px)');
|
||||||
|
|
||||||
|
touch('touchend', 220, 300, 150);
|
||||||
|
vi.advanceTimersByTime(280);
|
||||||
|
expect(back).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('drops a scheduled back navigation if the history changes first', () => {
|
||||||
|
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
||||||
|
const { getByTestId } = render(<Host />);
|
||||||
|
|
||||||
|
touch('touchstart', 5, 300, 0);
|
||||||
|
touch('touchmove', 200, 300, 100);
|
||||||
|
touch('touchend', 200, 300, 150);
|
||||||
|
window.dispatchEvent(new PopStateEvent('popstate'));
|
||||||
|
vi.advanceTimersByTime(280);
|
||||||
|
|
||||||
|
expect(getByTestId('page').style.transform).toBe('');
|
||||||
|
expect(back).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('drags the page with a finger from the left edge, and goes back past a third', () => {
|
it('drags the page with a finger from the left edge, and goes back past a third', () => {
|
||||||
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
||||||
const { getByTestId } = render(<Host />);
|
const { getByTestId } = render(<Host />);
|
||||||
@@ -63,6 +92,37 @@ describe('MEdgeBack', () => {
|
|||||||
expect(getByTestId('page').style.transform).toBe('');
|
expect(getByTestId('page').style.transform).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('cancels a swipe interrupted by the system even past the commit point', () => {
|
||||||
|
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
||||||
|
const { getByTestId } = render(<Host />);
|
||||||
|
|
||||||
|
touch('touchstart', 5);
|
||||||
|
touch('touchmove', 200, 300, 100);
|
||||||
|
touch('touchcancel', 200, 300, 105);
|
||||||
|
vi.advanceTimersByTime(300);
|
||||||
|
|
||||||
|
expect(getByTestId('page').style.transform).toBe('');
|
||||||
|
expect(back).not.toHaveBeenCalled();
|
||||||
|
expect(tickHaptic).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses the release speed and stops treating a held swipe as a flick', () => {
|
||||||
|
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
||||||
|
render(<Host />);
|
||||||
|
|
||||||
|
touch('touchstart', 5);
|
||||||
|
touch('touchmove', 65, 300, 40);
|
||||||
|
touch('touchend', 65, 300, 700);
|
||||||
|
vi.advanceTimersByTime(300);
|
||||||
|
expect(back).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
touch('touchstart', 5, 300, 800);
|
||||||
|
touch('touchmove', 65, 300, 840);
|
||||||
|
touch('touchend', 65, 300, 850);
|
||||||
|
vi.advanceTimersByTime(300);
|
||||||
|
expect(back).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('closes an open sheet first and leaves the page where it is', () => {
|
it('closes an open sheet first and leaves the page where it is', () => {
|
||||||
vi.mocked(hasOpenOverlay).mockReturnValue(true);
|
vi.mocked(hasOpenOverlay).mockReturnValue(true);
|
||||||
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
const back = vi.spyOn(window.history, 'back').mockImplementation(() => {});
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
import type { RefObject } from 'react';
|
import type { RefObject } from 'react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { closeTopOverlay, hasOpenOverlay } from '../../hooks/overlayStack';
|
||||||
import { tickHaptic } from '../../native/haptics';
|
import { tickHaptic } from '../../native/haptics';
|
||||||
import { closeTopOverlay, hasOpenOverlay } from '../overlayStack';
|
import {
|
||||||
|
currentTranslation,
|
||||||
|
isMotionReduced,
|
||||||
|
releaseVelocity,
|
||||||
|
sampleMotion,
|
||||||
|
type MotionSample,
|
||||||
|
} from '../gestureMotion';
|
||||||
import { skipNextRouteTransition } from '../routeTransition';
|
import { skipNextRouteTransition } from '../routeTransition';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The swipe from the left edge that goes back, the way every iOS app has it.
|
* The swipe from the leading edge that goes back on iOS.
|
||||||
*
|
*
|
||||||
* WebKit's own version slides away a screenshot of the whole page, closes no
|
* WebKit's own version slides away a screenshot of the whole page, closes no
|
||||||
* sheet and fights every gesture near the edge (the day pager, swipe rows), so
|
* sheet and fights every gesture near the edge (the day pager, swipe rows), so
|
||||||
@@ -16,7 +23,7 @@ import { skipNextRouteTransition } from '../routeTransition';
|
|||||||
* the `edgeBack` feature, so an older binary keeps WebKit's.
|
* the `edgeBack` feature, so an older binary keeps WebKit's.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** A touch has to start this close to the left edge. */
|
/** A touch has to start this close to the leading edge. */
|
||||||
const EDGE_PX = 22;
|
const EDGE_PX = 22;
|
||||||
/** Sideways must clearly beat vertical before the gesture is claimed. */
|
/** Sideways must clearly beat vertical before the gesture is claimed. */
|
||||||
const CLAIM_PX = 10;
|
const CLAIM_PX = 10;
|
||||||
@@ -33,35 +40,58 @@ function canGoBack(): boolean {
|
|||||||
export default function MEdgeBack({ target, enabled }: { target: RefObject<HTMLElement | null>; enabled: boolean }) {
|
export default function MEdgeBack({ target, enabled }: { target: RefObject<HTMLElement | null>; enabled: boolean }) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
let start: { x: number; y: number; t: number } | null = null;
|
let start: { x: number; y: number } | null = null;
|
||||||
let claimed = false;
|
let claimed = false;
|
||||||
let overlay = false;
|
let overlay = false;
|
||||||
let last = { x: 0, t: 0 };
|
let samples: MotionSample[] = [];
|
||||||
|
let grabOffset = 0;
|
||||||
|
let direction = 1;
|
||||||
|
let reducedMotion = false;
|
||||||
|
let navigationTimer: number | undefined;
|
||||||
|
let frame = 0;
|
||||||
|
|
||||||
const move = (x: number, transition: string) => {
|
const move = (x: number, transition: string) => {
|
||||||
const el = target.current;
|
const el = target.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
el.style.transition = transition;
|
el.style.transition = transition;
|
||||||
el.style.transform = x ? `translateX(${x}px)` : '';
|
el.style.transform = x ? `translateX(${x}px)` : '';
|
||||||
el.style.boxShadow = x ? '-16px 0 40px -12px rgba(0,0,0,.35)' : '';
|
el.style.boxShadow = x ? `${-16 * Math.sign(x)}px 0 40px -12px rgba(0,0,0,.35)` : '';
|
||||||
|
};
|
||||||
|
const settle = () => move(0, 'transform 260ms var(--ease-drawer), box-shadow 260ms');
|
||||||
|
|
||||||
|
const onCancel = () => {
|
||||||
|
if (claimed && !overlay) settle();
|
||||||
|
start = null;
|
||||||
|
claimed = false;
|
||||||
|
grabOffset = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetNavigation = () => {
|
||||||
|
window.clearTimeout(navigationTimer);
|
||||||
|
navigationTimer = undefined;
|
||||||
|
onCancel();
|
||||||
|
move(0, 'none');
|
||||||
};
|
};
|
||||||
|
|
||||||
const onStart = (e: TouchEvent) => {
|
const onStart = (e: TouchEvent) => {
|
||||||
claimed = false;
|
onCancel();
|
||||||
start = null;
|
|
||||||
if (e.touches.length !== 1) return;
|
if (e.touches.length !== 1) return;
|
||||||
const t = e.touches[0];
|
const t = e.touches[0];
|
||||||
if (t.clientX > EDGE_PX) return;
|
if (navigationTimer !== undefined) return;
|
||||||
|
direction = document.documentElement.dir === 'rtl' ? -1 : 1;
|
||||||
|
const edgeDistance = direction === 1 ? t.clientX : window.innerWidth - t.clientX;
|
||||||
|
if (edgeDistance > EDGE_PX) return;
|
||||||
overlay = hasOpenOverlay();
|
overlay = hasOpenOverlay();
|
||||||
if (!overlay && !canGoBack()) return;
|
if (!overlay && !canGoBack()) return;
|
||||||
start = { x: t.clientX, y: t.clientY, t: e.timeStamp };
|
reducedMotion = isMotionReduced();
|
||||||
last = { x: t.clientX, t: e.timeStamp };
|
start = { x: t.clientX, y: t.clientY };
|
||||||
|
samples = [{ position: t.clientX, time: e.timeStamp }];
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMove = (e: TouchEvent) => {
|
const onMove = (e: TouchEvent) => {
|
||||||
if (!start || e.touches.length !== 1) return;
|
if (!start || e.touches.length !== 1) return;
|
||||||
const t = e.touches[0];
|
const t = e.touches[0];
|
||||||
const dx = t.clientX - start.x;
|
const dx = direction * (t.clientX - start.x);
|
||||||
const dy = t.clientY - start.y;
|
const dy = t.clientY - start.y;
|
||||||
if (!claimed) {
|
if (!claimed) {
|
||||||
if (Math.abs(dy) > CLAIM_PX && Math.abs(dy) > Math.abs(dx)) {
|
if (Math.abs(dy) > CLAIM_PX && Math.abs(dy) > Math.abs(dx)) {
|
||||||
@@ -70,24 +100,26 @@ export default function MEdgeBack({ target, enabled }: { target: RefObject<HTMLE
|
|||||||
}
|
}
|
||||||
if (dx < CLAIM_PX || dx < Math.abs(dy) * AXIS_BIAS) return;
|
if (dx < CLAIM_PX || dx < Math.abs(dy) * AXIS_BIAS) return;
|
||||||
claimed = true;
|
claimed = true;
|
||||||
|
if (!overlay) grabOffset = direction * currentTranslation(target.current, 'x');
|
||||||
}
|
}
|
||||||
if (e.cancelable) e.preventDefault();
|
if (e.cancelable) e.preventDefault();
|
||||||
last = { x: t.clientX, t: e.timeStamp };
|
sampleMotion(samples, t.clientX, e.timeStamp);
|
||||||
// An open sheet closes on release; the page itself stays put under it.
|
// An open sheet closes on release; the page itself stays put under it.
|
||||||
if (!overlay) move(Math.max(0, dx), 'none');
|
if (!overlay && !reducedMotion) move(direction * Math.max(0, grabOffset + dx), 'none');
|
||||||
};
|
};
|
||||||
|
|
||||||
const onEnd = (e: TouchEvent) => {
|
const onEnd = (e: TouchEvent) => {
|
||||||
const s = start;
|
const s = start;
|
||||||
start = null;
|
start = null;
|
||||||
if (!s || !claimed) return;
|
if (!s || !claimed) return;
|
||||||
const x = e.changedTouches[0]?.clientX ?? last.x;
|
claimed = false;
|
||||||
const dx = Math.max(0, x - s.x);
|
const x = e.changedTouches[0]?.clientX ?? samples[samples.length - 1].position;
|
||||||
const v = (x - last.x) / Math.max(1, e.timeStamp - last.t) || dx / Math.max(1, e.timeStamp - s.t);
|
const dx = Math.max(0, grabOffset + direction * (x - s.x));
|
||||||
|
const v = direction * releaseVelocity(samples, x, e.timeStamp);
|
||||||
const width = window.innerWidth;
|
const width = window.innerWidth;
|
||||||
const commit = dx > width * COMMIT_SHARE || v > FLICK_V;
|
const commit = dx > 0 && (dx > width * COMMIT_SHARE || v > FLICK_V);
|
||||||
if (!commit) {
|
if (!commit) {
|
||||||
move(0, 'transform 260ms var(--ease-drawer), box-shadow 260ms');
|
if (!overlay) settle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tickHaptic();
|
tickHaptic();
|
||||||
@@ -95,24 +127,36 @@ export default function MEdgeBack({ target, enabled }: { target: RefObject<HTMLE
|
|||||||
closeTopOverlay();
|
closeTopOverlay();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
move(width, 'transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1)');
|
if (reducedMotion) {
|
||||||
window.setTimeout(() => {
|
skipNextRouteTransition();
|
||||||
|
window.history.back();
|
||||||
|
move(0, 'none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const duration = Math.round(Math.min(240, Math.max(120, (width - dx) / Math.max(v, 1.2))));
|
||||||
|
move(direction * width, `transform ${duration}ms cubic-bezier(0.2, 0.8, 0.2, 1)`);
|
||||||
|
navigationTimer = window.setTimeout(() => {
|
||||||
|
navigationTimer = undefined;
|
||||||
skipNextRouteTransition();
|
skipNextRouteTransition();
|
||||||
window.history.back();
|
window.history.back();
|
||||||
// The page that comes back takes the place without a slide of its own.
|
// The page that comes back takes the place without a slide of its own.
|
||||||
requestAnimationFrame(() => move(0, 'none'));
|
frame = requestAnimationFrame(() => move(0, 'none'));
|
||||||
}, 190);
|
}, duration);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('touchstart', onStart, { passive: true });
|
document.addEventListener('touchstart', onStart, { passive: true });
|
||||||
document.addEventListener('touchmove', onMove, { passive: false });
|
document.addEventListener('touchmove', onMove, { passive: false });
|
||||||
document.addEventListener('touchend', onEnd, { passive: true });
|
document.addEventListener('touchend', onEnd, { passive: true });
|
||||||
document.addEventListener('touchcancel', onEnd, { passive: true });
|
document.addEventListener('touchcancel', onCancel, { passive: true });
|
||||||
|
window.addEventListener('popstate', resetNavigation);
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener('touchstart', onStart);
|
document.removeEventListener('touchstart', onStart);
|
||||||
document.removeEventListener('touchmove', onMove);
|
document.removeEventListener('touchmove', onMove);
|
||||||
document.removeEventListener('touchend', onEnd);
|
document.removeEventListener('touchend', onEnd);
|
||||||
document.removeEventListener('touchcancel', onEnd);
|
document.removeEventListener('touchcancel', onCancel);
|
||||||
|
window.removeEventListener('popstate', resetNavigation);
|
||||||
|
window.clearTimeout(navigationTimer);
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
move(0, 'none');
|
move(0, 'none');
|
||||||
};
|
};
|
||||||
}, [enabled, target]);
|
}, [enabled, target]);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function MFab({ onClick, ariaLabel, className = '', children }: M
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
className={`flex h-14 w-14 flex-none items-center justify-center rounded-full bg-m-act text-m-actfg shadow-[0_8px_20px_-6px_rgba(0,0,0,.4)] ${className}`}
|
className={`m-round-control flex h-14 w-14 flex-none items-center justify-center rounded-full bg-m-act text-m-actfg shadow-[0_8px_20px_-6px_rgba(0,0,0,.4)] ${className}`}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default function MIconBtn({
|
|||||||
aria-expanded={ariaExpanded}
|
aria-expanded={ariaExpanded}
|
||||||
aria-haspopup={ariaHaspopup}
|
aria-haspopup={ariaHaspopup}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={`relative flex flex-none items-center justify-center rounded-full text-m-ink disabled:opacity-35 ${
|
className={`m-round-control relative flex flex-none items-center justify-center rounded-full text-m-ink disabled:opacity-35 ${
|
||||||
variant === 'glass'
|
variant === 'glass'
|
||||||
? 'border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)]'
|
? 'border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)]'
|
||||||
: 'bg-[color:var(--m-ic)]'
|
: 'bg-[color:var(--m-ic)]'
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
import { useEffect, useState, type ReactElement } from 'react';
|
import { useEffect, useRef, useState, type ReactElement } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
|
import { useOverlay } from '../../hooks/overlayStack';
|
||||||
import { useTranslation } from '../../i18n';
|
import { useTranslation } from '../../i18n';
|
||||||
import { lockBodyScroll } from '../../utils/bodyScrollLock';
|
import { lockBodyScroll } from '../../utils/bodyScrollLock';
|
||||||
|
import { keepTabInside, useModalFocus } from './modalFocus';
|
||||||
|
|
||||||
function sheetRoot(): HTMLElement {
|
function sheetRoot(): HTMLElement {
|
||||||
return document.getElementById('m-sheet-root') ?? document.body;
|
return document.getElementById('m-sheet-root') ?? document.body;
|
||||||
@@ -26,6 +28,9 @@ export default function MImageViewer({
|
|||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [zoomed, setZoomed] = useState(false);
|
const [zoomed, setZoomed] = useState(false);
|
||||||
|
const panel = useRef<HTMLDivElement>(null);
|
||||||
|
useOverlay(true, onClose);
|
||||||
|
useModalFocus(panel, true);
|
||||||
|
|
||||||
useEffect(() => lockBodyScroll(), []);
|
useEffect(() => lockBodyScroll(), []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -38,15 +43,21 @@ export default function MImageViewer({
|
|||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<div
|
<div
|
||||||
|
ref={panel}
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-label={alt}
|
aria-label={alt}
|
||||||
className="m-root fixed inset-0 z-[var(--z-overlay)] bg-[color:var(--m-viewer-bg)]"
|
tabIndex={-1}
|
||||||
|
className="m-root fixed inset-0 z-[var(--z-overlay)] bg-[color:var(--m-viewer-bg)] outline-none"
|
||||||
|
onKeyDown={(event) => keepTabInside(event, panel.current)}
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onClose}
|
onClick={(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
aria-label={t('collab.chat.closeImage')}
|
aria-label={t('collab.chat.closeImage')}
|
||||||
className="m-safe-row absolute end-4 top-[calc(var(--m-safe-top,12px)+4px)] z-10 flex h-10 w-10 items-center justify-center rounded-full bg-[color:var(--m-viewer-btn)] text-[color:var(--m-viewer-ink)]"
|
className="m-safe-row absolute end-4 top-[calc(var(--m-safe-top,12px)+4px)] z-10 flex h-10 w-10 items-center justify-center rounded-full bg-[color:var(--m-viewer-btn)] text-[color:var(--m-viewer-ink)]"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { Check, ChevronRight } from 'lucide-react';
|
||||||
|
import type { ComponentType, ReactNode } from 'react';
|
||||||
|
|
||||||
|
interface MMenuRowProps {
|
||||||
|
icon?: ComponentType<{ size?: number; strokeWidth?: number }>;
|
||||||
|
label: string;
|
||||||
|
value?: number;
|
||||||
|
valueLabel?: string;
|
||||||
|
trailing?: ReactNode;
|
||||||
|
current?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
onClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function MMenuRow({
|
||||||
|
icon: Icon,
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
valueLabel,
|
||||||
|
trailing,
|
||||||
|
current,
|
||||||
|
disabled,
|
||||||
|
onClick,
|
||||||
|
}: MMenuRowProps) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-current={current ? 'page' : undefined}
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={onClick}
|
||||||
|
className="flex min-h-12 w-full items-center gap-3 px-3 py-2 text-start active:bg-[color:var(--m-ic)]"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="grid size-8 flex-none place-items-center rounded-lg bg-[color:var(--m-ic)] text-m-muted"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
{Icon && <Icon size={17} strokeWidth={2} />}
|
||||||
|
</span>
|
||||||
|
<span dir="auto" className="min-w-0 flex-1 break-words text-body font-semibold text-m-ink">
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
{value != null && (
|
||||||
|
<span className="flex-none text-caption font-semibold tabular-nums text-m-muted">
|
||||||
|
<span aria-hidden={Boolean(valueLabel)}>{value}</span>
|
||||||
|
{valueLabel && <span className="sr-only">{valueLabel}</span>}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{trailing}
|
||||||
|
{current ? (
|
||||||
|
<Check size={16} aria-hidden="true" className="flex-none text-m-ink" />
|
||||||
|
) : (
|
||||||
|
<ChevronRight size={16} aria-hidden="true" className="flex-none text-m-muted rtl:rotate-180" />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -83,7 +83,7 @@ export default function MNavRail() {
|
|||||||
|
|
||||||
const path = location.pathname;
|
const path = location.pathname;
|
||||||
const nothingToCreate = path.startsWith('/settings') || path.startsWith('/admin');
|
const nothingToCreate = path.startsWith('/settings') || path.startsWith('/admin');
|
||||||
// /vacay draws its own action (the year/editor switch) into the head, as it
|
// /vacay draws its own action (jump to today) into the head, as it
|
||||||
// does into the dock's centre on the phone; until it has, the slot stays empty.
|
// does into the dock's centre on the phone; until it has, the slot stays empty.
|
||||||
const screenOwnsHead = path.startsWith('/vacay');
|
const screenOwnsHead = path.startsWith('/vacay');
|
||||||
const searchFab = path.startsWith('/atlas');
|
const searchFab = path.startsWith('/atlas');
|
||||||
|
|||||||
@@ -2,25 +2,16 @@ import { Monitor } from 'lucide-react';
|
|||||||
import { useTranslation } from '../../i18n';
|
import { useTranslation } from '../../i18n';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The one way the phone says "this is planned on a bigger screen": the road
|
* The mobile tour overview gives the planning location as an informational row.
|
||||||
* trip's empty stage and the tours list both carry it, so the sentence around
|
|
||||||
* it only has to say what the phone does instead.
|
|
||||||
*/
|
*/
|
||||||
export default function MPlanOnDesktopBadge({ className = '' }: { className?: string }) {
|
export default function MPlanOnDesktopBadge({ className = '' }: { className?: string }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`flex max-w-full items-center justify-center gap-2 text-caption text-m-muted ${className}`}>
|
||||||
className={`inline-flex max-w-full items-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] py-1 pe-3 ps-1 ${className}`}
|
<span aria-hidden="true" className="grid size-7 shrink-0 place-items-center rounded-lg bg-m-ic">
|
||||||
>
|
<Monitor size={15} strokeWidth={1.8} />
|
||||||
<span
|
|
||||||
aria-hidden="true"
|
|
||||||
className="flex h-6 w-6 flex-none items-center justify-center rounded-full bg-m-act text-m-actfg"
|
|
||||||
>
|
|
||||||
<Monitor size={12} strokeWidth={2.2} />
|
|
||||||
</span>
|
|
||||||
<span className="truncate font-geist text-[length:calc(11px*var(--fs-scale-caption,1))] font-semibold text-m-ink">
|
|
||||||
{t('mobileTrip.planOnDesktop')}
|
|
||||||
</span>
|
</span>
|
||||||
|
<span className="min-w-0 break-words leading-snug">{t('mobileTrip.planOnDesktop')}</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useTranslation } from '../../i18n'
|
|||||||
import { useDiscardGuard } from '../../components/shared/useDiscardGuard'
|
import { useDiscardGuard } from '../../components/shared/useDiscardGuard'
|
||||||
import { keepTabInside, useModalFocus } from './modalFocus'
|
import { keepTabInside, useModalFocus } from './modalFocus'
|
||||||
import { useSheetDrag } from './useSheetDrag'
|
import { useSheetDrag } from './useSheetDrag'
|
||||||
import { useOverlay } from '../overlayStack'
|
import { useOverlay } from '../../hooks/overlayStack'
|
||||||
import { tickHaptic } from '../../native/haptics'
|
import { tickHaptic } from '../../native/haptics'
|
||||||
import { useNativeQuestion } from '../../native/useNativeQuestion'
|
import { useNativeQuestion } from '../../native/useNativeQuestion'
|
||||||
|
|
||||||
@@ -215,9 +215,11 @@ export default function MSheet({
|
|||||||
// exit animation (which starts from the rest position) must not play.
|
// exit animation (which starts from the rest position) must not play.
|
||||||
const [flung, setFlung] = useState(false)
|
const [flung, setFlung] = useState(false)
|
||||||
const panelRef = useRef<HTMLDivElement>(null)
|
const panelRef = useRef<HTMLDivElement>(null)
|
||||||
|
const scrimRef = useRef<HTMLDivElement>(null)
|
||||||
const sheetDrag = useSheetDrag({
|
const sheetDrag = useSheetDrag({
|
||||||
enabled: variant === 'bottom' && open && rendered,
|
enabled: variant === 'bottom' && open && rendered,
|
||||||
panelRef,
|
panelRef,
|
||||||
|
scrimRef,
|
||||||
onDismiss: () => {
|
onDismiss: () => {
|
||||||
if (wouldAsk()) {
|
if (wouldAsk()) {
|
||||||
requestClose()
|
requestClose()
|
||||||
@@ -240,6 +242,11 @@ export default function MSheet({
|
|||||||
panel.style.transform = ''
|
panel.style.transform = ''
|
||||||
panel.style.transition = ''
|
panel.style.transition = ''
|
||||||
}
|
}
|
||||||
|
const scrim = scrimRef.current
|
||||||
|
if (scrim) {
|
||||||
|
scrim.style.opacity = ''
|
||||||
|
scrim.style.transition = ''
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setEntered(false)
|
setEntered(false)
|
||||||
@@ -249,32 +256,28 @@ export default function MSheet({
|
|||||||
return () => clearTimeout(t)
|
return () => clearTimeout(t)
|
||||||
}, [open, reset])
|
}, [open, reset])
|
||||||
|
|
||||||
// Escape belongs to the sheet on top only: a question opened over another
|
// The keyboard and native back gesture share the same order, including
|
||||||
// sheet closes alone, and the sheet under it stays open with whatever was
|
// popovers rendered by fields inside the sheet.
|
||||||
// typed into it. Sheets portal in the order they open, so the top one is the
|
const isTop = useOverlay(open && rendered, requestClose)
|
||||||
// last open panel in the document.
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return
|
if (!open || covered) return
|
||||||
const onKey = (e: KeyboardEvent) => {
|
const onKey = (e: KeyboardEvent) => {
|
||||||
if (e.key !== 'Escape') return
|
if (e.key !== 'Escape' || e.defaultPrevented || !isTop()) return
|
||||||
const openPanels = document.querySelectorAll('[data-m-sheet="open"]')
|
const openPanels = document.querySelectorAll('[data-m-sheet="open"]')
|
||||||
if (openPanels[openPanels.length - 1] !== panelRef.current) return
|
if (openPanels[openPanels.length - 1] !== panelRef.current) return
|
||||||
|
e.preventDefault()
|
||||||
if (asking) keepEditing()
|
if (asking) keepEditing()
|
||||||
else requestClose()
|
else requestClose()
|
||||||
}
|
}
|
||||||
document.addEventListener('keydown', onKey)
|
document.addEventListener('keydown', onKey)
|
||||||
return () => document.removeEventListener('keydown', onKey)
|
return () => document.removeEventListener('keydown', onKey)
|
||||||
}, [open, asking, keepEditing, requestClose])
|
}, [open, covered, asking, keepEditing, requestClose, isTop])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return
|
if (!open) return
|
||||||
return lockBodyScroll()
|
return lockBodyScroll()
|
||||||
}, [open])
|
}, [open])
|
||||||
|
|
||||||
// A way back (the edge swipe, Android's back gesture) closes the sheet on top
|
|
||||||
// first, through the same path as the scrim, so unsaved changes still ask.
|
|
||||||
useOverlay(open && rendered, requestClose)
|
|
||||||
|
|
||||||
// Move focus into the dialog on open, hand it back on close.
|
// Move focus into the dialog on open, hand it back on close.
|
||||||
useModalFocus(panelRef, open && rendered)
|
useModalFocus(panelRef, open && rendered)
|
||||||
|
|
||||||
@@ -300,11 +303,12 @@ export default function MSheet({
|
|||||||
if (e.target === e.currentTarget) requestClose()
|
if (e.target === e.currentTarget) requestClose()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div ref={scrimRef} aria-hidden="true" className="pointer-events-none absolute inset-0">
|
||||||
aria-hidden="true"
|
<div
|
||||||
data-m-scrim=""
|
data-m-scrim=""
|
||||||
className={`pointer-events-none absolute inset-0 ${dimTransparent ? 'bg-transparent short:bg-[color:var(--m-dim)]' : 'bg-[color:var(--m-dim)]'} ${open ? 'm-fade-in' : 'm-fade-out'}`}
|
className={`absolute inset-0 ${dimTransparent ? 'bg-transparent short:bg-[color:var(--m-dim)]' : 'bg-[color:var(--m-dim)]'} ${open ? 'm-fade-in' : 'm-fade-out'}`}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
<div className={regionClass(variant, wideAnchor, form)}>
|
<div className={regionClass(variant, wideAnchor, form)}>
|
||||||
<div className={boxClass(variant, wideWidth, form)}>
|
<div className={boxClass(variant, wideWidth, form)}>
|
||||||
<PopoverArrow variant={variant} anchor={wideAnchor} />
|
<PopoverArrow variant={variant} anchor={wideAnchor} />
|
||||||
|
|||||||
@@ -17,15 +17,15 @@ describe('MUserPickerList', () => {
|
|||||||
expect(rows.map((b) => b.textContent)).toEqual(['bob', 'carol']);
|
expect(rows.map((b) => b.textContent)).toEqual(['bob', 'carol']);
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
expect(row).toHaveAttribute('type', 'button');
|
expect(row).toHaveAttribute('type', 'button');
|
||||||
expect(row.className).not.toContain('bg-[color:var(--m-ic)]');
|
expect(row).toHaveAttribute('aria-pressed', 'false');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('FE-COMP-MUSERPICK-002: tints only the picked user', () => {
|
it('FE-COMP-MUSERPICK-002: tints only the picked user', () => {
|
||||||
render(<MUserPickerList users={users} selected={3} onPick={vi.fn()} />);
|
render(<MUserPickerList users={users} selected={3} onPick={vi.fn()} />);
|
||||||
|
|
||||||
expect(screen.getByRole('button', { name: 'carol' }).className).toContain('bg-[color:var(--m-ic)]');
|
expect(screen.getByRole('button', { name: 'carol' })).toHaveAttribute('aria-pressed', 'true');
|
||||||
expect(screen.getByRole('button', { name: 'bob' }).className).not.toContain('bg-[color:var(--m-ic)]');
|
expect(screen.getByRole('button', { name: 'bob' })).toHaveAttribute('aria-pressed', 'false');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('FE-COMP-MUSERPICK-003: hands the tapped user id to onPick', () => {
|
it('FE-COMP-MUSERPICK-003: hands the tapped user id to onPick', () => {
|
||||||
|
|||||||
@@ -1,28 +1,52 @@
|
|||||||
|
import { Check, ChevronDown, UserRound } from 'lucide-react';
|
||||||
|
|
||||||
interface MUserPickerListProps {
|
interface MUserPickerListProps {
|
||||||
users: { id: number; username: string }[];
|
users: { id: number; username: string }[];
|
||||||
selected: number | null;
|
selected: number | null;
|
||||||
onPick: (id: number) => void;
|
onPick: (id: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The unfolded user list under a phone sheet's user picker (the vacay invite
|
|
||||||
* and share sheets): one row per user, the picked one tinted.
|
|
||||||
*/
|
|
||||||
export default function MUserPickerList({ users, selected, onPick }: MUserPickerListProps) {
|
export default function MUserPickerList({ users, selected, onPick }: MUserPickerListProps) {
|
||||||
return (
|
return (
|
||||||
<div className="mt-[6px] max-h-[180px] overflow-y-auto rounded-[14px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheetop)] p-[6px]">
|
<div className="mt-2 max-h-48 divide-y divide-m-rowbr overflow-y-auto rounded-xl bg-m-sheetop px-2">
|
||||||
{users.map((u) => (
|
{users.map((user) => (
|
||||||
<button
|
<button
|
||||||
key={u.id}
|
key={user.id}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onPick(u.id)}
|
onClick={() => onPick(user.id)}
|
||||||
className={`flex w-full items-center gap-[9px] rounded-[10px] px-[10px] py-[9px] text-start text-[0.8125rem] font-semibold ${
|
aria-pressed={user.id === selected}
|
||||||
u.id === selected ? 'bg-[color:var(--m-ic)]' : ''
|
className="flex min-h-11 w-full items-center gap-2 rounded-lg px-2 text-start text-control font-medium active:bg-m-ic aria-pressed:bg-m-ic"
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<span className="min-w-0 flex-1 truncate">{u.username}</span>
|
<UserRound size={16} className="shrink-0 text-m-muted" aria-hidden />
|
||||||
|
<span dir="auto" className="min-w-0 flex-1 truncate">
|
||||||
|
{user.username}
|
||||||
|
</span>
|
||||||
|
{user.id === selected && <Check size={16} className="shrink-0" aria-hidden />}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MUserPickerFieldProps extends MUserPickerListProps {
|
||||||
|
label: string;
|
||||||
|
placeholder: string;
|
||||||
|
open: boolean;
|
||||||
|
onToggle: () => void;
|
||||||
|
fieldClass: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MUserPickerField({ label, placeholder, open, onToggle, fieldClass, ...list }: MUserPickerFieldProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button type="button" onClick={onToggle} aria-expanded={open} className={`${fieldClass} gap-2 text-start`}>
|
||||||
|
<UserRound size={16} className="shrink-0 text-m-muted" aria-hidden />
|
||||||
|
<span dir="auto" className={`min-w-0 flex-1 truncate ${list.selected === null ? 'text-m-muted' : ''}`}>
|
||||||
|
{label || placeholder}
|
||||||
|
</span>
|
||||||
|
<ChevronDown size={16} className={`shrink-0 text-m-muted ${open ? 'rotate-180' : ''}`} aria-hidden />
|
||||||
|
</button>
|
||||||
|
{open && <MUserPickerList {...list} />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ describe('NativeImportSheet', () => {
|
|||||||
act(() => useSharedImportStore.getState().setFile(new File(['x'], 'booking.pdf', { type: 'application/pdf' })));
|
act(() => useSharedImportStore.getState().setFile(new File(['x'], 'booking.pdf', { type: 'application/pdf' })));
|
||||||
|
|
||||||
const rows = await screen.findAllByRole('button', { name: /Japan|Past trip/ });
|
const rows = await screen.findAllByRole('button', { name: /Japan|Past trip/ });
|
||||||
expect(rows.map((r) => r.textContent)).toEqual(['Japan', 'Past trip']);
|
expect(rows[0]).toHaveAccessibleName(/^Japan/);
|
||||||
|
expect(rows[1]).toHaveAccessibleName(/^Past trip/);
|
||||||
expect(screen.getByText('booking.pdf')).toBeInTheDocument();
|
expect(screen.getByText('booking.pdf')).toBeInTheDocument();
|
||||||
|
|
||||||
fireEvent.click(rows[0]);
|
fireEvent.click(rows[0]);
|
||||||
@@ -79,6 +80,59 @@ describe('NativeImportSheet', () => {
|
|||||||
expect(navigate).toHaveBeenCalledTimes(1);
|
expect(navigate).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('opens the selected trip even if the current trip has the same ID prefix', () => {
|
||||||
|
render(<NativeImportSheet />, { initialEntries: ['/trips/10/files'] });
|
||||||
|
act(() => {
|
||||||
|
useSharedImportStore.getState().setFile(new File(['x'], 'booking.pdf', { type: 'application/pdf' }));
|
||||||
|
useSharedImportStore.getState().chooseTrip(1);
|
||||||
|
});
|
||||||
|
expect(navigate).toHaveBeenCalledWith('/trips/1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can retry loading trips without losing the shared document', async () => {
|
||||||
|
vi.mocked(tripRepo.list).mockRejectedValueOnce(new Error('offline'));
|
||||||
|
const document = new File(['x'], 'booking.pdf', { type: 'application/pdf' });
|
||||||
|
render(<NativeImportSheet />);
|
||||||
|
act(() => useSharedImportStore.getState().setFile(document));
|
||||||
|
|
||||||
|
expect(await screen.findByText('Failed to load trips')).toBeInTheDocument();
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
|
||||||
|
expect(await screen.findByRole('button', { name: /^Japan/ })).toBeInTheDocument();
|
||||||
|
expect(useSharedImportStore.getState().file).toBe(document);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes back a choice of link action without discarding the shared link', async () => {
|
||||||
|
const source = page();
|
||||||
|
render(<NativeImportSheet />);
|
||||||
|
act(() => useSharedImportStore.getState().setFile(source, link()));
|
||||||
|
|
||||||
|
fireEvent.click(await screen.findByRole('button', { name: /Read a booking from it/ }));
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Back' }));
|
||||||
|
expect(screen.getByRole('button', { name: /Save to the trip's links/ })).toBeInTheDocument();
|
||||||
|
expect(useSharedImportStore.getState().file).toBe(source);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps a second shared document if the previous link finishes saving', async () => {
|
||||||
|
let finish = () => {};
|
||||||
|
vi.mocked(saveSharedLink).mockImplementation(
|
||||||
|
() =>
|
||||||
|
new Promise((resolve) => {
|
||||||
|
finish = resolve;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
render(<NativeImportSheet />);
|
||||||
|
act(() => useSharedImportStore.getState().setFile(bareLink(), link(2)));
|
||||||
|
await waitFor(() => expect(saveSharedLink).toHaveBeenCalled());
|
||||||
|
|
||||||
|
const next = new File(['x'], 'booking.pdf', { type: 'application/pdf' });
|
||||||
|
act(() => useSharedImportStore.getState().setFile(next));
|
||||||
|
await act(async () => finish());
|
||||||
|
|
||||||
|
expect(useSharedImportStore.getState().file).toBe(next);
|
||||||
|
expect(navigate).not.toHaveBeenCalled();
|
||||||
|
expect(screen.getByText('booking.pdf')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it('asks what a shared page is for, and keeps it among the links of the trip picked', async () => {
|
it('asks what a shared page is for, and keeps it among the links of the trip picked', async () => {
|
||||||
render(<NativeImportSheet />);
|
render(<NativeImportSheet />);
|
||||||
act(() => useSharedImportStore.getState().setFile(page(), link()));
|
act(() => useSharedImportStore.getState().setFile(page(), link()));
|
||||||
|
|||||||
@@ -10,9 +10,20 @@
|
|||||||
* A map link (Google Maps, Amap) can also become a place of the
|
* A map link (Google Maps, Amap) can also become a place of the
|
||||||
* trip (#2582): the trip's new place sheet opens and looks the link up.
|
* trip (#2582): the trip's new place sheet opens and looks the link up.
|
||||||
*/
|
*/
|
||||||
import { ChevronRight, FileText, Link2, MapPin, ScanText } from 'lucide-react';
|
import {
|
||||||
|
ChevronLeft,
|
||||||
|
ChevronRight,
|
||||||
|
FileText,
|
||||||
|
Link2,
|
||||||
|
Loader2,
|
||||||
|
Luggage,
|
||||||
|
MapPin,
|
||||||
|
ScanText,
|
||||||
|
Search,
|
||||||
|
type LucideIcon,
|
||||||
|
} from 'lucide-react';
|
||||||
import React, { useEffect, useEffectEvent, useRef, useState } from 'react';
|
import React, { useEffect, useEffectEvent, useRef, useState } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router';
|
import { matchPath, useLocation, useNavigate } from 'react-router';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { isMapUrl } from '../../components/Planner/PlaceFormModal.helpers';
|
import { isMapUrl } from '../../components/Planner/PlaceFormModal.helpers';
|
||||||
import { useToast } from '../../components/shared/Toast';
|
import { useToast } from '../../components/shared/Toast';
|
||||||
@@ -22,9 +33,15 @@ import { tripRepo } from '../../repo/tripRepo';
|
|||||||
import { useAddonStore } from '../../store/addonStore';
|
import { useAddonStore } from '../../store/addonStore';
|
||||||
import { tripAddonsEntry, useTripAddonsStore } from '../../store/tripAddonsStore';
|
import { tripAddonsEntry, useTripAddonsStore } from '../../store/tripAddonsStore';
|
||||||
import { getApiErrorMessage } from '../../utils/apiError';
|
import { getApiErrorMessage } from '../../utils/apiError';
|
||||||
|
import { formatDate } from '../../utils/formatters';
|
||||||
|
import { sortTripsByRelevance } from '../../utils/heroTrip';
|
||||||
|
import { localIsoDate } from '../../utils/localDate';
|
||||||
import { offlineOr } from '../../utils/needsConnection';
|
import { offlineOr } from '../../utils/needsConnection';
|
||||||
|
import { textMatchesSearch } from '../../utils/placeSearch';
|
||||||
import { tripAddonEnabled } from '../../utils/tripAddons';
|
import { tripAddonEnabled } from '../../utils/tripAddons';
|
||||||
import { TileHeader } from '../screens/trip/sheets/MTripSheetUi';
|
import { SHEET_SECONDARY } from '../screens/trip/sheets/MTripSheetUi';
|
||||||
|
import { AMOUNT_FIELD_CLS, FormSheetBody, FormSheetHeader } from '../screens/trip/sheets/PlSheetChrome';
|
||||||
|
import MIconBtn from './MIconBtn';
|
||||||
import MSheet from './MSheet';
|
import MSheet from './MSheet';
|
||||||
|
|
||||||
interface TripRow {
|
interface TripRow {
|
||||||
@@ -81,33 +98,31 @@ function sheetTitle(t: (key: string) => string, asking: boolean, choice: LinkCho
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NO_TRIPS: TripRow[] = [];
|
const NO_TRIPS: TripRow[] = [];
|
||||||
|
const LOADING_TRIPS = { trips: NO_TRIPS, status: 'loading' } as const;
|
||||||
|
|
||||||
/** The trips to choose from, those still ahead first, and whether they are read yet. */
|
type TripRows = { trips: TripRow[]; status: 'loading' | 'ready' | 'error' };
|
||||||
function useTripRows(open: boolean): { trips: TripRow[]; loaded: boolean } {
|
|
||||||
const [rows, setRows] = useState<{ trips: TripRow[]; loaded: boolean }>({ trips: NO_TRIPS, loaded: false });
|
/** Read the same trips and relevance order as the dashboard. */
|
||||||
|
function useTripRows(open: boolean) {
|
||||||
|
const [rows, setRows] = useState<TripRows>(LOADING_TRIPS);
|
||||||
|
const [attempt, setAttempt] = useState(0);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
let live = true;
|
let live = true;
|
||||||
tripRepo.list().then(
|
tripRepo.list().then(
|
||||||
(data: { trips?: TripRow[] }) => {
|
({ trips }) => {
|
||||||
const today = new Date().toISOString().slice(0, 10);
|
if (live) setRows({ trips: sortTripsByRelevance(trips ?? [], localIsoDate()), status: 'ready' });
|
||||||
const list = [...(data.trips ?? [])];
|
|
||||||
const ahead = (trip: TripRow) => (trip.end_date ?? '9999') >= today;
|
|
||||||
list.sort(
|
|
||||||
(a, b) => Number(ahead(b)) - Number(ahead(a)) || (a.start_date ?? '').localeCompare(b.start_date ?? '')
|
|
||||||
);
|
|
||||||
if (live) setRows({ trips: list, loaded: true });
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
if (live) setRows({ trips: NO_TRIPS, loaded: true });
|
if (live) setRows({ trips: NO_TRIPS, status: 'error' });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return () => {
|
return () => {
|
||||||
live = false;
|
live = false;
|
||||||
setRows({ trips: NO_TRIPS, loaded: false });
|
setRows(LOADING_TRIPS);
|
||||||
};
|
};
|
||||||
}, [open]);
|
}, [open, attempt]);
|
||||||
return rows;
|
return { ...rows, retry: () => setAttempt((value) => value + 1) };
|
||||||
}
|
}
|
||||||
|
|
||||||
const NOTHING_READ: ReadonlySet<number> = new Set();
|
const NOTHING_READ: ReadonlySet<number> = new Set();
|
||||||
@@ -165,15 +180,16 @@ export default function NativeImportSheet(): React.ReactElement | null {
|
|||||||
const setFile = useSharedImportStore((s) => s.setFile);
|
const setFile = useSharedImportStore((s) => s.setFile);
|
||||||
const instanceCollab = useAddonStore((s) => s.isEnabled('collab'));
|
const instanceCollab = useAddonStore((s) => s.isEnabled('collab'));
|
||||||
const open = !!file && tripId == null;
|
const open = !!file && tripId == null;
|
||||||
const { trips, loaded: tripsLoaded } = useTripRows(open);
|
const { trips, status: tripsStatus, retry } = useTripRows(open);
|
||||||
const { collabTrips, settled } = useCollabTrips(trips, open && !!link);
|
const { collabTrips, settled } = useCollabTrips(trips, open && !!link);
|
||||||
// Without a trip of its own to ask, the instance switch decides, as it always did.
|
// Without a trip of its own to ask, the instance switch decides, as it always did.
|
||||||
const collabOn = trips.length === 0 ? instanceCollab : collabTrips.length > 0;
|
const collabOn = trips.length === 0 ? instanceCollab : collabTrips.length > 0;
|
||||||
// Both belong to the item they were made for, so a newly shared one starts afresh.
|
// Both belong to the item they were made for, so a newly shared one starts afresh.
|
||||||
const [pick, setPick] = useState<{ file: File; choice: LinkChoice } | null>(null);
|
const [pick, setPick] = useState<{ file: File; choice: LinkChoice } | null>(null);
|
||||||
const [failedFile, setFailedFile] = useState<File | null>(null);
|
const [failedFile, setFailedFile] = useState<File | null>(null);
|
||||||
// The save in flight, kept off the state: it guards a second tap, it is not shown.
|
const inFlight = useRef(new Set<File>());
|
||||||
const savingRef = useRef<File | null>(null);
|
const [saving, setSaving] = useState<{ file: File; tripId: number } | null>(null);
|
||||||
|
const savingTrip = saving?.file === file ? saving.tripId : null;
|
||||||
const picked = pick && pick.file === file ? pick.choice : null;
|
const picked = pick && pick.file === file ? pick.choice : null;
|
||||||
const { choice, asking, nowhere, choices, showTrips } = stageOf({
|
const { choice, asking, nowhere, choices, showTrips } = stageOf({
|
||||||
file,
|
file,
|
||||||
@@ -181,32 +197,36 @@ export default function NativeImportSheet(): React.ReactElement | null {
|
|||||||
collabOn,
|
collabOn,
|
||||||
picked,
|
picked,
|
||||||
presetFailed: failedFile != null && failedFile === file,
|
presetFailed: failedFile != null && failedFile === file,
|
||||||
settled: tripsLoaded && settled,
|
settled: tripsStatus === 'ready' && settled,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Once a trip is picked (here, or in the share sheet before the app opened), go to
|
// Once a trip is picked (here, or in the share sheet before the app opened), go to
|
||||||
// it; its planner opens the booking import with the file (MTripShell).
|
// it; its planner opens the booking import with the file (MTripShell).
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!file || tripId == null || pathname.startsWith(`/trips/${tripId}`)) return;
|
if (!file || tripId == null) return;
|
||||||
|
const currentTrip = matchPath({ path: '/trips/:tripId', end: false }, pathname)?.params.tripId;
|
||||||
|
if (currentTrip === String(tripId)) return;
|
||||||
void navigate(`/trips/${tripId}`);
|
void navigate(`/trips/${tripId}`);
|
||||||
}, [file, tripId, pathname, navigate]);
|
}, [file, tripId, pathname, navigate]);
|
||||||
|
|
||||||
const saveLink = (id: number) => {
|
const saveLink = async (id: number) => {
|
||||||
if (!link || !file || savingRef.current === file) return;
|
if (!link || !file || inFlight.current.has(file)) return;
|
||||||
savingRef.current = file;
|
inFlight.current.add(file);
|
||||||
saveSharedLink(id, link).then(
|
setSaving({ file, tripId: id });
|
||||||
() => {
|
try {
|
||||||
toast.success(t('native.share.linkSaved'));
|
await saveSharedLink(id, link);
|
||||||
setFile(null);
|
if (useSharedImportStore.getState().file !== file) return;
|
||||||
void navigate(`/trips/${id}?tab=collab`);
|
toast.success(t('native.share.linkSaved'));
|
||||||
},
|
setFile(null);
|
||||||
(err: unknown) => {
|
void navigate(`/trips/${id}?tab=collab`);
|
||||||
// The server says why, such as a trip that has Collaboration off.
|
} catch (err) {
|
||||||
toast.error(offlineOr(t, getApiErrorMessage(err, t('common.error'))));
|
if (useSharedImportStore.getState().file !== file) return;
|
||||||
savingRef.current = null;
|
toast.error(offlineOr(t, getApiErrorMessage(err, t('common.error'))));
|
||||||
setFailedFile(file);
|
setFailedFile(file);
|
||||||
}
|
} finally {
|
||||||
);
|
inFlight.current.delete(file);
|
||||||
|
setSaving((current) => (current?.file === file ? null : current));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// The trip's new place sheet takes the map link from here (MTripShell, MPlaceEditSheet).
|
// The trip's new place sheet takes the map link from here (MTripShell, MPlaceEditSheet).
|
||||||
@@ -220,134 +240,180 @@ export default function NativeImportSheet(): React.ReactElement | null {
|
|||||||
const applyPreset = useEffectEvent((id: number, use: LinkChoice) => {
|
const applyPreset = useEffectEvent((id: number, use: LinkChoice) => {
|
||||||
if (use === 'booking') chooseTrip(id);
|
if (use === 'booking') chooseTrip(id);
|
||||||
else if (use === 'place') addPlace(id);
|
else if (use === 'place') addPlace(id);
|
||||||
else if (failedFile !== file) saveLink(id);
|
else if (failedFile !== file) void saveLink(id);
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (preset != null && choice != null && file) applyPreset(preset, choice);
|
if (preset != null && choice != null && file) applyPreset(preset, choice);
|
||||||
}, [preset, choice, file]);
|
}, [preset, choice, file]);
|
||||||
|
|
||||||
const pickTrip = (id: number) => {
|
const pickTrip = (id: number) => {
|
||||||
if (choice === 'link') saveLink(id);
|
if (choice === 'link') void saveLink(id);
|
||||||
else if (choice === 'place') addPlace(id);
|
else if (choice === 'place') addPlace(id);
|
||||||
else chooseTrip(id);
|
else chooseTrip(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const title = sheetTitle(t, asking, choice);
|
||||||
|
const sourceName = link?.title ?? file?.name;
|
||||||
|
const close = () => setFile(null);
|
||||||
|
const back = picked && choices.length > 1 && savingTrip == null ? () => setPick(null) : undefined;
|
||||||
|
const loading = tripsStatus === 'loading' || (!asking && !showTrips && !nowhere);
|
||||||
return (
|
return (
|
||||||
<MSheet open={open} onClose={() => setFile(null)} variant="bottom" ariaLabel={t('native.share.title')}>
|
<MSheet open={open} onClose={back ?? close} variant="bottom" ariaLabel={title} form>
|
||||||
<div className="px-[18px] pb-4 pt-4">
|
<FormSheetHeader
|
||||||
<div className="mb-3">
|
icon={link ? Link2 : FileText}
|
||||||
<TileHeader
|
leading={
|
||||||
icon={link ? <Link2 size={19} strokeWidth={1.8} /> : <FileText size={19} strokeWidth={1.8} />}
|
back && (
|
||||||
title={sheetTitle(t, asking, choice)}
|
<MIconBtn variant="neutral" size={40} ariaLabel={t('common.back')} onClick={back}>
|
||||||
sub={link ? link.title : file?.name}
|
<ChevronLeft size={19} className="rtl:rotate-180" aria-hidden />
|
||||||
onClose={() => setFile(null)}
|
</MIconBtn>
|
||||||
closeLabel={t('common.close')}
|
)
|
||||||
/>
|
}
|
||||||
</div>
|
title={title}
|
||||||
{asking && file && <LinkQuestion choices={choices} onPick={(use) => setPick({ file, choice: use })} />}
|
subtitle={sourceName && <bdi>{sourceName}</bdi>}
|
||||||
{nowhere && (
|
onClose={close}
|
||||||
<p className="px-1 text-[length:calc(12px*var(--fs-scale-body,1))] text-m-muted">
|
closeLabel={t('common.close')}
|
||||||
{t('native.share.linkUnsupported')}
|
/>
|
||||||
|
<FormSheetBody className="space-y-3">
|
||||||
|
{tripsStatus === 'error' ? (
|
||||||
|
<div className="space-y-3 rounded-[14px] bg-m-ic p-3">
|
||||||
|
<p role="status" className="text-control text-m-muted">
|
||||||
|
{t('dashboard.toast.loadError')}
|
||||||
|
</p>
|
||||||
|
<button type="button" className={SHEET_SECONDARY} onClick={retry}>
|
||||||
|
{t('common.errorRetry')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : loading ? (
|
||||||
|
<p role="status" className="flex items-center gap-2 rounded-[14px] bg-m-ic p-3 text-control text-m-muted">
|
||||||
|
<Loader2 size={16} className="animate-spin" aria-hidden />
|
||||||
|
{t(savingTrip == null ? 'common.loading' : 'common.saving')}
|
||||||
</p>
|
</p>
|
||||||
|
) : asking && file ? (
|
||||||
|
<LinkQuestion choices={choices} onPick={(use) => setPick({ file, choice: use })} />
|
||||||
|
) : nowhere ? (
|
||||||
|
<p className="rounded-[14px] bg-m-ic p-3 text-control text-m-muted">{t('native.share.linkUnsupported')}</p>
|
||||||
|
) : (
|
||||||
|
showTrips && (
|
||||||
|
<TripPicker
|
||||||
|
key={choice}
|
||||||
|
trips={choice === 'link' ? collabTrips : trips}
|
||||||
|
savingTrip={savingTrip}
|
||||||
|
onPick={pickTrip}
|
||||||
|
/>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
{showTrips && <TripPicker trips={choice === 'link' ? collabTrips : trips} onPick={pickTrip} />}
|
</FormSheetBody>
|
||||||
</div>
|
|
||||||
</MSheet>
|
</MSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LinkQuestion({
|
function LinkQuestion({ choices, onPick }: { choices: LinkChoice[]; onPick: (choice: LinkChoice) => void }) {
|
||||||
choices,
|
|
||||||
onPick,
|
|
||||||
}: {
|
|
||||||
choices: LinkChoice[];
|
|
||||||
onPick: (choice: LinkChoice) => void;
|
|
||||||
}): React.ReactElement {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const actions = {
|
||||||
|
place: { Icon: MapPin, label: t('native.share.addPlace'), hint: t('native.share.addPlaceHint') },
|
||||||
|
link: { Icon: Link2, label: t('native.share.saveLink'), hint: t('native.share.saveLinkHint') },
|
||||||
|
booking: { Icon: ScanText, label: t('native.share.readBooking'), hint: t('native.share.readBookingHint') },
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="divide-y divide-m-rowbr rounded-[14px] bg-m-ic px-3">
|
||||||
{choices.includes('place') && (
|
{choices.map((choice) => {
|
||||||
<ChoiceRow
|
const { Icon, label, hint } = actions[choice];
|
||||||
icon={<MapPin size={17} strokeWidth={2} />}
|
return <ChoiceRow key={choice} icon={Icon} label={label} hint={hint} onClick={() => onPick(choice)} />;
|
||||||
label={t('native.share.addPlace')}
|
})}
|
||||||
hint={t('native.share.addPlaceHint')}
|
|
||||||
onClick={() => onPick('place')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{choices.includes('link') && (
|
|
||||||
<ChoiceRow
|
|
||||||
icon={<Link2 size={17} strokeWidth={2} />}
|
|
||||||
label={t('native.share.saveLink')}
|
|
||||||
hint={t('native.share.saveLinkHint')}
|
|
||||||
onClick={() => onPick('link')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{choices.includes('booking') && (
|
|
||||||
<ChoiceRow
|
|
||||||
icon={<ScanText size={17} strokeWidth={2} />}
|
|
||||||
label={t('native.share.readBooking')}
|
|
||||||
hint={t('native.share.readBookingHint')}
|
|
||||||
onClick={() => onPick('booking')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TripPicker({ trips, onPick }: { trips: TripRow[]; onPick: (id: number) => void }): React.ReactElement {
|
function TripPicker({
|
||||||
const { t } = useTranslation();
|
trips,
|
||||||
|
savingTrip,
|
||||||
|
onPick,
|
||||||
|
}: {
|
||||||
|
trips: TripRow[];
|
||||||
|
savingTrip: number | null;
|
||||||
|
onPick: (id: number) => void;
|
||||||
|
}) {
|
||||||
|
const { t, locale } = useTranslation();
|
||||||
|
const [query, setQuery] = useState('');
|
||||||
|
const matching = trips.filter((trip) => textMatchesSearch([trip.title], query));
|
||||||
|
if (trips.length === 0)
|
||||||
|
return <p className="rounded-[14px] bg-m-ic p-3 text-control text-m-muted">{t('native.share.noTrips')}</p>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex max-h-[50vh] flex-col gap-2 overflow-y-auto">
|
<>
|
||||||
{trips.map((trip) => (
|
{trips.length > 6 && (
|
||||||
<button
|
<label className={AMOUNT_FIELD_CLS}>
|
||||||
key={trip.id}
|
<Search size={16} className="flex-none text-m-muted" aria-hidden />
|
||||||
type="button"
|
<input
|
||||||
onClick={() => onPick(trip.id)}
|
type="search"
|
||||||
className="flex items-center gap-3 rounded-[16px] border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] px-4 py-3 text-start transition-transform active:scale-[.98] disabled:opacity-50"
|
value={query}
|
||||||
>
|
onChange={(event) => setQuery(event.target.value)}
|
||||||
<span className="min-w-0 flex-1 truncate text-[length:calc(14px*var(--fs-scale-body,1))] font-bold text-m-ink">
|
enterKeyHint="search"
|
||||||
{trip.title}
|
aria-label={t('common.search')}
|
||||||
</span>
|
placeholder={t('common.search')}
|
||||||
<ChevronRight size={16} className="flex-none text-m-faint" aria-hidden="true" />
|
className="min-w-0 flex-1 bg-transparent py-2 text-control outline-none"
|
||||||
</button>
|
/>
|
||||||
))}
|
</label>
|
||||||
{trips.length === 0 && (
|
|
||||||
<p className="px-1 text-[length:calc(12px*var(--fs-scale-body,1))] text-m-muted">{t('native.share.noTrips')}</p>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
<div className="divide-y divide-m-rowbr rounded-[14px] bg-m-ic px-3">
|
||||||
|
{matching.map((trip) => (
|
||||||
|
<ChoiceRow
|
||||||
|
key={trip.id}
|
||||||
|
icon={Luggage}
|
||||||
|
label={trip.title}
|
||||||
|
hint={formatDate(trip.start_date, locale)}
|
||||||
|
busy={savingTrip === trip.id}
|
||||||
|
disabled={savingTrip != null}
|
||||||
|
onClick={() => onPick(trip.id)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
{matching.length === 0 && (
|
||||||
|
<p role="status" className="py-3 text-control text-m-muted">
|
||||||
|
{t('collections.empty.noMatchTitle')}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChoiceRow({
|
function ChoiceRow({
|
||||||
icon,
|
icon: Icon,
|
||||||
label,
|
label,
|
||||||
hint,
|
hint,
|
||||||
|
busy,
|
||||||
|
disabled,
|
||||||
onClick,
|
onClick,
|
||||||
}: {
|
}: {
|
||||||
icon: React.ReactNode;
|
icon: LucideIcon;
|
||||||
label: string;
|
label: string;
|
||||||
hint: string;
|
hint: string | null;
|
||||||
|
busy?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}): React.ReactElement {
|
}) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className="flex items-center gap-3 rounded-[16px] border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] px-4 py-3 text-start transition-transform active:scale-[.98]"
|
disabled={disabled}
|
||||||
|
aria-busy={busy || undefined}
|
||||||
|
className="flex min-h-12 w-full items-center gap-3 py-2 text-start disabled:opacity-60"
|
||||||
>
|
>
|
||||||
<span
|
<span className="grid size-8 flex-none place-items-center rounded-lg bg-m-sheetop text-m-muted" aria-hidden>
|
||||||
className="flex h-9 w-9 flex-none items-center justify-center rounded-full bg-[color:var(--m-ic)] text-m-ink"
|
<Icon size={16} strokeWidth={2} />
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
{icon}
|
|
||||||
</span>
|
</span>
|
||||||
<span className="min-w-0 flex-1">
|
<span className="min-w-0 flex-1">
|
||||||
<span className="block truncate text-[length:calc(14px*var(--fs-scale-body,1))] font-bold text-m-ink">
|
<span dir="auto" className="block break-words text-control font-semibold text-m-ink">
|
||||||
{label}
|
{label}
|
||||||
</span>
|
</span>
|
||||||
<span className="block truncate text-[length:calc(12px*var(--fs-scale-body,1))] text-m-muted">{hint}</span>
|
{hint && <span className="mt-0.5 block text-caption leading-snug text-m-muted">{hint}</span>}
|
||||||
</span>
|
</span>
|
||||||
<ChevronRight size={16} className="flex-none text-m-faint" aria-hidden="true" />
|
{busy ? (
|
||||||
|
<Loader2 size={16} className="flex-none animate-spin text-m-muted" aria-hidden />
|
||||||
|
) : (
|
||||||
|
<ChevronRight size={16} className="flex-none text-m-muted rtl:rotate-180" aria-hidden />
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,11 @@ export function useModalFocus(panel: RefObject<HTMLElement | null>, shown: boole
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!shown) return;
|
if (!shown) return;
|
||||||
const previous = document.activeElement as HTMLElement | null;
|
const previous = document.activeElement as HTMLElement | null;
|
||||||
panel.current?.focus();
|
const element = panel.current;
|
||||||
return () => previous?.focus();
|
element?.focus();
|
||||||
|
return () => {
|
||||||
|
const active = document.activeElement;
|
||||||
|
if (active === document.body || element?.contains(active)) previous?.focus();
|
||||||
|
};
|
||||||
}, [panel, shown]);
|
}, [panel, shown]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import { create } from 'zustand';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A screen's own action at the head of the navigation rail, in the place the
|
* A screen's own action at the head of the navigation rail, in the place the
|
||||||
* "+" holds elsewhere: the vacation calendar's switch between the year and the
|
* "+" holds elsewhere, such as the vacation calendar's jump to today.
|
||||||
* editor. On the phone the same screen draws it into the dock's centre slot.
|
* On the phone the same screen draws it into the dock's centre slot.
|
||||||
*/
|
*/
|
||||||
export interface RailAction {
|
export interface RailAction {
|
||||||
label: string;
|
label: string;
|
||||||
icon: LucideIcon;
|
icon: LucideIcon;
|
||||||
/** On: drawn as a ring rather than filled (the editor is open). */
|
/** An active toggle is drawn as a ring rather than a filled button. */
|
||||||
pressed?: boolean;
|
pressed?: boolean;
|
||||||
run: () => void;
|
run: () => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import type { MutableRefObject, PointerEvent as ReactPointerEvent, RefObject } from 'react';
|
import type { MutableRefObject, PointerEvent as ReactPointerEvent, RefObject } from 'react';
|
||||||
import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
||||||
|
import {
|
||||||
|
currentTranslation,
|
||||||
|
isMotionReduced,
|
||||||
|
releaseVelocity,
|
||||||
|
sampleMotion,
|
||||||
|
type MotionSample,
|
||||||
|
} from '../gestureMotion';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drag-to-dismiss for the docked bottom sheet, the way a native sheet takes it.
|
* Drag-to-dismiss for the docked bottom sheet, the way a native sheet takes it.
|
||||||
@@ -27,8 +34,6 @@ const AXIS_BIAS = 1.2;
|
|||||||
const DISMISS_SHARE = 0.3;
|
const DISMISS_SHARE = 0.3;
|
||||||
/** px/ms downward at release that dismisses on its own. */
|
/** px/ms downward at release that dismisses on its own. */
|
||||||
const FLICK_V = 0.5;
|
const FLICK_V = 0.5;
|
||||||
/** Speed is read over this trailing window. */
|
|
||||||
const SAMPLE_MS = 80;
|
|
||||||
/** Upward pull: a fraction of the travel, capped, as a stretch rather than a move. */
|
/** Upward pull: a fraction of the travel, capped, as a stretch rather than a move. */
|
||||||
const STRETCH = 0.2;
|
const STRETCH = 0.2;
|
||||||
const STRETCH_MAX = 20;
|
const STRETCH_MAX = 20;
|
||||||
@@ -41,7 +46,7 @@ const OWNS_GESTURE =
|
|||||||
interface Drag {
|
interface Drag {
|
||||||
y0: number;
|
y0: number;
|
||||||
x0: number;
|
x0: number;
|
||||||
samples: { y: number; t: number }[];
|
samples: MotionSample[];
|
||||||
claimed: boolean;
|
claimed: boolean;
|
||||||
scroller: HTMLElement | null;
|
scroller: HTMLElement | null;
|
||||||
}
|
}
|
||||||
@@ -60,20 +65,16 @@ function offsetFor(dy: number): number {
|
|||||||
return dy >= 0 ? dy : -Math.min(STRETCH_MAX, -dy * STRETCH);
|
return dy >= 0 ? dy : -Math.min(STRETCH_MAX, -dy * STRETCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sample(d: Drag, y: number, t: number): void {
|
|
||||||
d.samples.push({ y, t });
|
|
||||||
while (d.samples.length > 2 && t - d.samples[0].t > SAMPLE_MS) d.samples.shift();
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SheetDragOptions {
|
export interface SheetDragOptions {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
panelRef: RefObject<HTMLElement | null>;
|
panelRef: RefObject<HTMLElement | null>;
|
||||||
|
scrimRef: RefObject<HTMLElement | null>;
|
||||||
/** Called on a dismissing release. Returns true when the sheet will close, so
|
/** Called on a dismissing release. Returns true when the sheet will close, so
|
||||||
* it can be thrown off screen; false (an unsaved-changes question) springs it back. */
|
* it can be thrown off screen; false (an unsaved-changes question) springs it back. */
|
||||||
onDismiss: () => boolean;
|
onDismiss: () => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSheetDrag({ enabled, panelRef, onDismiss }: SheetDragOptions) {
|
export function useSheetDrag({ enabled, panelRef, scrimRef, onDismiss }: SheetDragOptions) {
|
||||||
const drag = useRef<Drag | null>(null);
|
const drag = useRef<Drag | null>(null);
|
||||||
const frame = useRef(0);
|
const frame = useRef(0);
|
||||||
const latest = useRef(onDismiss);
|
const latest = useRef(onDismiss);
|
||||||
@@ -85,12 +86,25 @@ export function useSheetDrag({ enabled, panelRef, onDismiss }: SheetDragOptions)
|
|||||||
(y: number, transition: string) => {
|
(y: number, transition: string) => {
|
||||||
const el = panelRef.current;
|
const el = panelRef.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
|
const scrim = scrimRef.current;
|
||||||
|
const travel = el.offsetHeight;
|
||||||
el.style.transition = transition;
|
el.style.transition = transition;
|
||||||
el.style.transform = `translateY(${y}px)`;
|
el.style.transform = `translateY(${y}px)`;
|
||||||
|
if (scrim && travel > 0) {
|
||||||
|
scrim.style.transition = transition.replace('transform ', 'opacity ');
|
||||||
|
scrim.style.opacity = String(1 - Math.min(1, Math.max(0, y / travel)));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[panelRef]
|
[panelRef, scrimRef]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const cancelDrag = useCallback(() => {
|
||||||
|
cancelAnimationFrame(frame.current);
|
||||||
|
const claimed = drag.current?.claimed;
|
||||||
|
drag.current = null;
|
||||||
|
if (claimed) write(0, isMotionReduced() ? 'none' : SPRING_BACK);
|
||||||
|
}, [write]);
|
||||||
|
|
||||||
const follow = useCallback(
|
const follow = useCallback(
|
||||||
(dy: number) => {
|
(dy: number) => {
|
||||||
cancelAnimationFrame(frame.current);
|
cancelAnimationFrame(frame.current);
|
||||||
@@ -103,24 +117,22 @@ export function useSheetDrag({ enabled, panelRef, onDismiss }: SheetDragOptions)
|
|||||||
);
|
);
|
||||||
|
|
||||||
const release = useCallback(
|
const release = useCallback(
|
||||||
(d: Drag, lastY: number) => {
|
(d: Drag, lastY: number, time: number) => {
|
||||||
cancelAnimationFrame(frame.current);
|
cancelAnimationFrame(frame.current);
|
||||||
const el = panelRef.current;
|
const el = panelRef.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
const dy = lastY - d.y0;
|
const dy = lastY - d.y0;
|
||||||
const first = d.samples[0];
|
const v = releaseVelocity(d.samples, lastY, time);
|
||||||
const last = d.samples[d.samples.length - 1];
|
|
||||||
const v = first && last ? (last.y - first.y) / Math.max(1, last.t - first.t) : 0;
|
|
||||||
const height = el.offsetHeight;
|
const height = el.offsetHeight;
|
||||||
const dismiss = dy > 0 && ((height > 0 && dy > height * DISMISS_SHARE) || v > FLICK_V);
|
const dismiss = dy > 0 && ((height > 0 && dy > height * DISMISS_SHARE) || v > FLICK_V);
|
||||||
if (dismiss && latest.current()) {
|
if (dismiss && latest.current()) {
|
||||||
// Off screen from where the finger let go, faster the harder the flick.
|
// Off screen from where the finger let go, faster the harder the flick.
|
||||||
const distance = Math.max(height, window.innerHeight - el.getBoundingClientRect().top + dy) + 24;
|
const distance = Math.max(height, window.innerHeight - el.getBoundingClientRect().top + dy) + 24;
|
||||||
const ms = Math.round(Math.min(320, Math.max(160, (distance - dy) / Math.max(v, 1.2))));
|
const ms = Math.round(Math.min(320, Math.max(160, (distance - dy) / Math.max(v, 1.2))));
|
||||||
write(distance, `transform ${ms}ms cubic-bezier(0.2, 0.8, 0.2, 1)`);
|
write(distance, isMotionReduced() ? 'none' : `transform ${ms}ms cubic-bezier(0.2, 0.8, 0.2, 1)`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
write(0, SPRING_BACK);
|
write(0, isMotionReduced() ? 'none' : SPRING_BACK);
|
||||||
},
|
},
|
||||||
[panelRef, write]
|
[panelRef, write]
|
||||||
);
|
);
|
||||||
@@ -129,22 +141,23 @@ export function useSheetDrag({ enabled, panelRef, onDismiss }: SheetDragOptions)
|
|||||||
const onStripPointerDown = useCallback(
|
const onStripPointerDown = useCallback(
|
||||||
(e: ReactPointerEvent) => {
|
(e: ReactPointerEvent) => {
|
||||||
(e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);
|
(e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);
|
||||||
|
const offset = currentTranslation(panelRef.current, 'y');
|
||||||
drag.current = {
|
drag.current = {
|
||||||
y0: e.clientY,
|
y0: e.clientY - offset,
|
||||||
x0: e.clientX,
|
x0: e.clientX,
|
||||||
samples: [{ y: e.clientY, t: e.timeStamp }],
|
samples: [{ position: e.clientY, time: e.timeStamp }],
|
||||||
claimed: true,
|
claimed: true,
|
||||||
scroller: null,
|
scroller: null,
|
||||||
};
|
};
|
||||||
write(0, 'none');
|
write(offset, 'none');
|
||||||
},
|
},
|
||||||
[write]
|
[panelRef, write]
|
||||||
);
|
);
|
||||||
const onStripPointerMove = useCallback(
|
const onStripPointerMove = useCallback(
|
||||||
(e: ReactPointerEvent) => {
|
(e: ReactPointerEvent) => {
|
||||||
const d = drag.current;
|
const d = drag.current;
|
||||||
if (!d?.claimed) return;
|
if (!d?.claimed) return;
|
||||||
sample(d, e.clientY, e.timeStamp);
|
sampleMotion(d.samples, e.clientY, e.timeStamp);
|
||||||
follow(e.clientY - d.y0);
|
follow(e.clientY - d.y0);
|
||||||
},
|
},
|
||||||
[follow]
|
[follow]
|
||||||
@@ -155,7 +168,7 @@ export function useSheetDrag({ enabled, panelRef, onDismiss }: SheetDragOptions)
|
|||||||
drag.current = null;
|
drag.current = null;
|
||||||
if (!d?.claimed) return;
|
if (!d?.claimed) return;
|
||||||
const last = d.samples[d.samples.length - 1];
|
const last = d.samples[d.samples.length - 1];
|
||||||
release(d, Number.isFinite(e.clientY) && e.clientY !== 0 ? e.clientY : last.y);
|
release(d, Number.isFinite(e.clientY) && e.clientY !== 0 ? e.clientY : last.position, e.timeStamp);
|
||||||
},
|
},
|
||||||
[release]
|
[release]
|
||||||
);
|
);
|
||||||
@@ -165,8 +178,8 @@ export function useSheetDrag({ enabled, panelRef, onDismiss }: SheetDragOptions)
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const panel = panelRef.current;
|
const panel = panelRef.current;
|
||||||
if (!enabled || !panel) return;
|
if (!enabled || !panel) return;
|
||||||
return attachContentDrag(panel, drag, frame, follow, release);
|
return attachContentDrag(panel, drag, frame, follow, release, cancelDrag);
|
||||||
}, [enabled, panelRef, follow, release]);
|
}, [enabled, panelRef, follow, release, cancelDrag]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
strip: {
|
strip: {
|
||||||
@@ -174,7 +187,8 @@ export function useSheetDrag({ enabled, panelRef, onDismiss }: SheetDragOptions)
|
|||||||
onPointerDown: onStripPointerDown,
|
onPointerDown: onStripPointerDown,
|
||||||
onPointerMove: onStripPointerMove,
|
onPointerMove: onStripPointerMove,
|
||||||
onPointerUp: onStripPointerEnd,
|
onPointerUp: onStripPointerEnd,
|
||||||
onPointerCancel: onStripPointerEnd,
|
onPointerCancel: cancelDrag,
|
||||||
|
onLostPointerCapture: cancelDrag,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -188,7 +202,8 @@ function attachContentDrag(
|
|||||||
drag: MutableRefObject<Drag | null>,
|
drag: MutableRefObject<Drag | null>,
|
||||||
frame: MutableRefObject<number>,
|
frame: MutableRefObject<number>,
|
||||||
follow: (dy: number) => void,
|
follow: (dy: number) => void,
|
||||||
release: (d: Drag, lastY: number) => void
|
release: (d: Drag, lastY: number, time: number) => void,
|
||||||
|
cancelDrag: () => void
|
||||||
): () => void {
|
): () => void {
|
||||||
/** Set by a claimed drag: the click the browser sends after it is not a tap. */
|
/** Set by a claimed drag: the click the browser sends after it is not a tap. */
|
||||||
let swallowClick = false;
|
let swallowClick = false;
|
||||||
@@ -197,7 +212,13 @@ function attachContentDrag(
|
|||||||
const el = target as Element | null;
|
const el = target as Element | null;
|
||||||
if (el?.closest?.('[data-sheet-grab]') || el?.closest?.(OWNS_GESTURE)) return false;
|
if (el?.closest?.('[data-sheet-grab]') || el?.closest?.(OWNS_GESTURE)) return false;
|
||||||
swallowClick = false;
|
swallowClick = false;
|
||||||
drag.current = { y0: y, x0: x, samples: [{ y, t }], claimed: false, scroller: nearestScroller(target, panel) };
|
drag.current = {
|
||||||
|
y0: y,
|
||||||
|
x0: x,
|
||||||
|
samples: [{ position: y, time: t }],
|
||||||
|
claimed: false,
|
||||||
|
scroller: nearestScroller(target, panel),
|
||||||
|
};
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
/** False once the gesture is not ours, so the caller lets it go. */
|
/** False once the gesture is not ours, so the caller lets it go. */
|
||||||
@@ -215,25 +236,25 @@ function attachContentDrag(
|
|||||||
}
|
}
|
||||||
d.claimed = true;
|
d.claimed = true;
|
||||||
// Measured from here, so the sheet does not jump by the classify slop.
|
// Measured from here, so the sheet does not jump by the classify slop.
|
||||||
d.y0 = y;
|
d.y0 = y - currentTranslation(panel, 'y');
|
||||||
d.samples = [{ y, t }];
|
d.samples = [{ position: y, time: t }];
|
||||||
}
|
}
|
||||||
sample(d, y, t);
|
sampleMotion(d.samples, y, t);
|
||||||
follow(y - d.y0);
|
follow(y - d.y0);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const finish = (y: number | undefined) => {
|
const finish = (y: number | undefined, time: number) => {
|
||||||
const d = drag.current;
|
const d = drag.current;
|
||||||
drag.current = null;
|
drag.current = null;
|
||||||
if (!d?.claimed) return;
|
if (!d?.claimed) return;
|
||||||
swallowClick = true;
|
swallowClick = true;
|
||||||
const last = d.samples[d.samples.length - 1];
|
const last = d.samples[d.samples.length - 1];
|
||||||
release(d, y ?? last.y);
|
release(d, y ?? last.position, time);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onTouchStart = (e: TouchEvent) => {
|
const onTouchStart = (e: TouchEvent) => {
|
||||||
if (e.touches.length !== 1) {
|
if (e.touches.length !== 1) {
|
||||||
drag.current = null;
|
cancelDrag();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const t = e.touches[0];
|
const t = e.touches[0];
|
||||||
@@ -244,7 +265,7 @@ function attachContentDrag(
|
|||||||
const t = e.touches[0];
|
const t = e.touches[0];
|
||||||
if (advance(t.clientX, t.clientY, e.timeStamp) && drag.current?.claimed && e.cancelable) e.preventDefault();
|
if (advance(t.clientX, t.clientY, e.timeStamp) && drag.current?.claimed && e.cancelable) e.preventDefault();
|
||||||
};
|
};
|
||||||
const onTouchEnd = (e: TouchEvent) => finish(e.changedTouches[0]?.clientY);
|
const onTouchEnd = (e: TouchEvent) => finish(e.changedTouches[0]?.clientY, e.timeStamp);
|
||||||
|
|
||||||
// Touch has its own path above: a touch pointer is cancelled the moment the
|
// Touch has its own path above: a touch pointer is cancelled the moment the
|
||||||
// browser starts scrolling, so only mouse and pen come through here.
|
// browser starts scrolling, so only mouse and pen come through here.
|
||||||
@@ -265,7 +286,8 @@ function attachContentDrag(
|
|||||||
};
|
};
|
||||||
const onPointerUp = (e: PointerEvent) => {
|
const onPointerUp = (e: PointerEvent) => {
|
||||||
stopPointer();
|
stopPointer();
|
||||||
finish(e.type === 'pointercancel' ? undefined : e.clientY);
|
if (e.type === 'pointercancel') cancelDrag();
|
||||||
|
else finish(e.clientY, e.timeStamp);
|
||||||
};
|
};
|
||||||
const stopPointer = () => {
|
const stopPointer = () => {
|
||||||
window.removeEventListener('pointermove', onPointerMove);
|
window.removeEventListener('pointermove', onPointerMove);
|
||||||
@@ -282,7 +304,7 @@ function attachContentDrag(
|
|||||||
panel.addEventListener('touchstart', onTouchStart, { passive: true });
|
panel.addEventListener('touchstart', onTouchStart, { passive: true });
|
||||||
panel.addEventListener('touchmove', onTouchMove, { passive: false });
|
panel.addEventListener('touchmove', onTouchMove, { passive: false });
|
||||||
panel.addEventListener('touchend', onTouchEnd, { passive: true });
|
panel.addEventListener('touchend', onTouchEnd, { passive: true });
|
||||||
panel.addEventListener('touchcancel', onTouchEnd, { passive: true });
|
panel.addEventListener('touchcancel', cancelDrag, { passive: true });
|
||||||
panel.addEventListener('pointerdown', onPointerDown);
|
panel.addEventListener('pointerdown', onPointerDown);
|
||||||
panel.addEventListener('click', onClickCapture, true);
|
panel.addEventListener('click', onClickCapture, true);
|
||||||
return () => {
|
return () => {
|
||||||
@@ -291,7 +313,7 @@ function attachContentDrag(
|
|||||||
panel.removeEventListener('touchstart', onTouchStart);
|
panel.removeEventListener('touchstart', onTouchStart);
|
||||||
panel.removeEventListener('touchmove', onTouchMove);
|
panel.removeEventListener('touchmove', onTouchMove);
|
||||||
panel.removeEventListener('touchend', onTouchEnd);
|
panel.removeEventListener('touchend', onTouchEnd);
|
||||||
panel.removeEventListener('touchcancel', onTouchEnd);
|
panel.removeEventListener('touchcancel', cancelDrag);
|
||||||
panel.removeEventListener('pointerdown', onPointerDown);
|
panel.removeEventListener('pointerdown', onPointerDown);
|
||||||
panel.removeEventListener('click', onClickCapture, true);
|
panel.removeEventListener('click', onClickCapture, true);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
export interface MotionSample {
|
||||||
|
position: number;
|
||||||
|
time: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VELOCITY_WINDOW_MS = 80;
|
||||||
|
|
||||||
|
export function isMotionReduced(): boolean {
|
||||||
|
return (
|
||||||
|
document.documentElement.hasAttribute('data-reduce-motion') ||
|
||||||
|
(window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sampleMotion(samples: MotionSample[], position: number, time: number): void {
|
||||||
|
samples.push({ position, time });
|
||||||
|
while (samples.length > 2 && time - samples[0].time > VELOCITY_WINDOW_MS) samples.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function releaseVelocity(samples: MotionSample[], position: number, time: number): number {
|
||||||
|
sampleMotion(samples, position, time);
|
||||||
|
const first = samples[0];
|
||||||
|
const duration = time - first.time;
|
||||||
|
return duration > 0 && duration <= VELOCITY_WINDOW_MS ? (position - first.position) / duration : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function currentTranslation(element: HTMLElement | null, axis: 'x' | 'y'): number {
|
||||||
|
if (!element || typeof DOMMatrixReadOnly === 'undefined') return 0;
|
||||||
|
const transform = getComputedStyle(element).transform;
|
||||||
|
if (transform === 'none' || !transform) return 0;
|
||||||
|
const matrix = new DOMMatrixReadOnly(transform);
|
||||||
|
return axis === 'x' ? matrix.m41 : matrix.m42;
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { hasOpenOverlay, useHasOpenOverlay } from '../../hooks/overlayStack';
|
||||||
import { useNativeCapabilities } from '../../native/capabilities';
|
import { useNativeCapabilities } from '../../native/capabilities';
|
||||||
import { isNativeApp, isNativeIos } from '../../native/platform';
|
import { isNativeApp, isNativeIos } from '../../native/platform';
|
||||||
import { reportNativeFailure } from '../../native/reportFailure';
|
import { reportNativeFailure } from '../../native/reportFailure';
|
||||||
import { TrekShell } from '../../native/trekShell';
|
import { TrekShell } from '../../native/trekShell';
|
||||||
import { hasOpenOverlay, useHasOpenOverlay } from '../overlayStack';
|
|
||||||
import { findShortcut, toNativeCommand, useShortcutRegistry } from './shortcuts';
|
import { findShortcut, toNativeCommand, useShortcutRegistry } from './shortcuts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+171
-160
@@ -5,16 +5,16 @@
|
|||||||
*/
|
*/
|
||||||
.m-root {
|
.m-root {
|
||||||
--m-ink: #101013;
|
--m-ink: #101013;
|
||||||
--m-muted: #68686F;
|
--m-muted: #565761;
|
||||||
--m-faint: #9A9AA1;
|
--m-faint: #6C6D76;
|
||||||
--m-bg: #F3F2EF;
|
--m-bg: #F2F2F7;
|
||||||
--m-scr: radial-gradient(120% 80% at 50% -10%, #FBFAF7 0%, #F1EFEA 55%, #E9E7E1 100%);
|
--m-scr: none;
|
||||||
--m-glass: rgba(255,255,255,.6);
|
--m-glass: rgba(255,255,255,.6);
|
||||||
/* The dock's glass: denser than --m-glass, so a photo scrolling under it
|
/* The dock's glass: denser than --m-glass, so a photo scrolling under it
|
||||||
* neither turns it muddy nor washes out its icons. */
|
* neither turns it muddy nor washes out its icons. */
|
||||||
--m-dock: rgba(255,255,255,.8);
|
--m-dock: rgba(255,255,255,.8);
|
||||||
--m-gbr: rgba(255,255,255,.75);
|
--m-gbr: rgba(255,255,255,.75);
|
||||||
--m-card: rgba(255,255,255,.55);
|
--m-card: #FFFFFF;
|
||||||
--m-cbr: rgba(255,255,255,.75);
|
--m-cbr: rgba(255,255,255,.75);
|
||||||
--m-inner: rgba(255,255,255,.68);
|
--m-inner: rgba(255,255,255,.68);
|
||||||
--m-inbr: rgba(255,255,255,.9);
|
--m-inbr: rgba(255,255,255,.9);
|
||||||
@@ -25,12 +25,12 @@
|
|||||||
--m-viewer-bg: rgba(0,0,0,.92);
|
--m-viewer-bg: rgba(0,0,0,.92);
|
||||||
--m-viewer-ink: #fff;
|
--m-viewer-ink: #fff;
|
||||||
--m-viewer-btn: rgba(255,255,255,.15);
|
--m-viewer-btn: rgba(255,255,255,.15);
|
||||||
--m-sheet: rgba(250,250,248,.94);
|
--m-sheet: #FFFFFF;
|
||||||
--m-sheetop: #FAFAF8;
|
--m-sheetop: #FFFFFF;
|
||||||
--m-shbr: rgba(255,255,255,.95);
|
--m-shbr: rgba(255,255,255,.95);
|
||||||
--m-ic: rgba(16,16,19,.04);
|
--m-ic: rgba(16,16,19,.04);
|
||||||
--m-avbr: rgba(255,255,255,.9);
|
--m-avbr: rgba(255,255,255,.9);
|
||||||
--m-rowbr: rgba(16,16,19,.045);
|
--m-rowbr: rgba(16,16,19,.10);
|
||||||
--m-conn: #9A9AA1;
|
--m-conn: #9A9AA1;
|
||||||
--m-mapb: #E8E6E1;
|
--m-mapb: #E8E6E1;
|
||||||
--m-mapr: #FBFAF8;
|
--m-mapr: #FBFAF8;
|
||||||
@@ -252,154 +252,6 @@ html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── TREK mascot (empty-state) — logo-as-body character, per-scene props ───── */
|
|
||||||
@keyframes trek-idle { 0%, 100% { transform: translateY(0) rotate(-1.1deg); } 50% { transform: translateY(-2px) rotate(1.1deg); } }
|
|
||||||
@keyframes trek-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012, 1.024); } }
|
|
||||||
@keyframes trek-shadow { 0%, 100% { transform: scaleX(1); opacity: .15; } 50% { transform: scaleX(1.05); opacity: .17; } }
|
|
||||||
/* body hop, occasional: long rest, then anticipation squash → airborne → land → settle */
|
|
||||||
@keyframes trek-hop {
|
|
||||||
0%, 74%, 100% { transform: translateY(0) scale(1, 1); }
|
|
||||||
79% { transform: translateY(1px) scale(1.05, .92); }
|
|
||||||
87% { transform: translateY(-10px) scale(.95, 1.07); }
|
|
||||||
94% { transform: translateY(0) scale(1.07, .93); }
|
|
||||||
98% { transform: translateY(0) scale(.99, 1.01); }
|
|
||||||
}
|
|
||||||
/* body nod — a pleased look left-and-right, e.g. cheering the poll results */
|
|
||||||
@keyframes trek-nod {
|
|
||||||
0%, 100% { transform: translateY(0) rotate(0); }
|
|
||||||
25% { transform: translateY(-2px) rotate(-4deg); }
|
|
||||||
50% { transform: translateY(0) rotate(0); }
|
|
||||||
75% { transform: translateY(-2px) rotate(4deg); }
|
|
||||||
}
|
|
||||||
/* slow blink: eyes squeeze shut for a couple of frames each cycle */
|
|
||||||
@keyframes trek-blink { 0%, 90%, 100% { transform: scaleY(1); } 94%, 97% { transform: scaleY(.12); } }
|
|
||||||
/* entrance / poke-to-react pop-in (plays on mount and on each remount/tap) */
|
|
||||||
@keyframes trek-in {
|
|
||||||
0% { opacity: 0; transform: translateY(7px) scale(.85); }
|
|
||||||
60% { opacity: 1; }
|
|
||||||
100% { opacity: 1; transform: translateY(0) scale(1); }
|
|
||||||
}
|
|
||||||
/* pupils glancing around — centred most of the time, occasional look down/side */
|
|
||||||
@keyframes trek-look {
|
|
||||||
0%, 34%, 100% { transform: translate(0, 0); }
|
|
||||||
42%, 52% { transform: translate(0, .9px); }
|
|
||||||
64%, 72% { transform: translate(.9px, .1px); }
|
|
||||||
84%, 90% { transform: translate(-.8px, .2px); }
|
|
||||||
}
|
|
||||||
/* wheels rolling in place */
|
|
||||||
@keyframes trek-roll { to { transform: rotate(360deg); } }
|
|
||||||
/* skateboard ollie — body and board pop off the ground together, now and then */
|
|
||||||
@keyframes trek-sk-body {
|
|
||||||
0%, 68%, 100% { transform: translateY(0) scale(1, 1); }
|
|
||||||
73% { transform: translateY(1.5px) scale(1.04, .95); }
|
|
||||||
84% { transform: translateY(-9px) scale(.97, 1.05); }
|
|
||||||
92% { transform: translateY(0) scale(1.05, .95); }
|
|
||||||
96% { transform: translateY(0) scale(1, 1); }
|
|
||||||
}
|
|
||||||
@keyframes trek-sk-board {
|
|
||||||
0%, 68%, 100% { transform: translateY(0) rotate(0); }
|
|
||||||
73% { transform: translateY(0) rotate(-6deg); }
|
|
||||||
84% { transform: translateY(-8px) rotate(7deg); }
|
|
||||||
90% { transform: translateY(-3px) rotate(-3deg); }
|
|
||||||
95% { transform: translateY(0) rotate(0); }
|
|
||||||
}
|
|
||||||
/* guide pennant fluttering — pivots at the pole */
|
|
||||||
@keyframes trek-flag {
|
|
||||||
0%, 100% { transform: skewY(0) scaleX(1); }
|
|
||||||
30% { transform: skewY(-7deg) scaleX(.96); }
|
|
||||||
60% { transform: skewY(6deg) scaleX(1.03); }
|
|
||||||
}
|
|
||||||
/* poll bars staying up, gently rising and settling like live tallies */
|
|
||||||
@keyframes trek-bar { 0%, 100% { transform: scaleY(.78); } 50% { transform: scaleY(1); } }
|
|
||||||
@keyframes trek-typing { 0%, 70%, 100% { transform: scale(.5); opacity: .4; } 35% { transform: scale(1); opacity: 1; } }
|
|
||||||
/* card / note rocking gently */
|
|
||||||
@keyframes trek-ticket { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
|
|
||||||
/* a line being written: draws in from the left, holds, then a fresh pass */
|
|
||||||
@keyframes trek-write {
|
|
||||||
0% { transform: scaleX(0); }
|
|
||||||
30%, 82% { transform: scaleX(1); }
|
|
||||||
92%, 100% { transform: scaleX(0); }
|
|
||||||
}
|
|
||||||
/* pencil scribbling as the lines appear */
|
|
||||||
@keyframes trek-pencil {
|
|
||||||
0%, 100% { transform: translate(0, 0) rotate(0); }
|
|
||||||
20% { transform: translate(-1.5px, 1.5px) rotate(-4deg); }
|
|
||||||
45% { transform: translate(1.5px, -.5px) rotate(3deg); }
|
|
||||||
70% { transform: translate(-1px, 1px) rotate(-2deg); }
|
|
||||||
}
|
|
||||||
/* suitcase rocking on its wheels, restless to get going */
|
|
||||||
@keyframes trek-suitcase { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
|
|
||||||
/* suitcase handle telescoping up and down */
|
|
||||||
@keyframes trek-handle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
|
|
||||||
/* collections map pin bobbing */
|
|
||||||
@keyframes trek-pin { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
|
|
||||||
/* Chain: the pair sways, and the near link slides out along its own axis and
|
|
||||||
clicks back in. Moving only the near one keeps the joint readable at 88px. */
|
|
||||||
@keyframes trek-chain { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-6deg); } }
|
|
||||||
@keyframes trek-link { 0%, 62%, 100% { transform: translateX(0); } 30% { transform: translateX(2.6px); } }
|
|
||||||
/* atlas globe meridian drifting to fake a slow spin */
|
|
||||||
@keyframes trek-globe { 0%, 100% { transform: translateX(-2px); } 50% { transform: translateX(2px); } }
|
|
||||||
/* costs top coin bouncing on */
|
|
||||||
@keyframes trek-coin { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } 55% { transform: translateY(0); } 70% { transform: translateY(-2px); } 84% { transform: translateY(0); } }
|
|
||||||
/* journey page turning over the spine */
|
|
||||||
@keyframes trek-page { 0%, 55%, 100% { transform: scaleX(1); } 78% { transform: scaleX(-.9); } }
|
|
||||||
/* dashboard paper plane bobbing in flight */
|
|
||||||
@keyframes trek-plane { 0%, 100% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(-1px, -2px) rotate(-4deg); } 50% { transform: translate(0, 0) rotate(0); } 75% { transform: translate(1px, 2px) rotate(4deg); } }
|
|
||||||
/* notifications Zzz drifting up and fading */
|
|
||||||
@keyframes trek-z { 0% { opacity: 0; transform: translate(0, 4px) scale(.7); } 30% { opacity: .9; } 100% { opacity: 0; transform: translate(3px, -8px) scale(1.1); } }
|
|
||||||
/* search magnifier scanning */
|
|
||||||
@keyframes trek-magnifier { 0%, 100% { transform: translateX(-3px) rotate(-3deg); } 50% { transform: translateX(3px) rotate(3deg); } }
|
|
||||||
/* to-do checkmark ticking on, holding, then resetting */
|
|
||||||
@keyframes trek-check { 0%, 8% { transform: scale(0); } 22% { transform: scale(1.2); } 32%, 88% { transform: scale(1); } 96%, 100% { transform: scale(0); } }
|
|
||||||
/* tours: a walking step, the pole swinging forward and planting, the pack riding along */
|
|
||||||
@keyframes trek-walk { 0%, 50%, 100% { transform: translateY(0); } 25%, 75% { transform: translateY(-1.6px); } }
|
|
||||||
@keyframes trek-pole { 0%, 100% { transform: rotate(-9deg); } 45% { transform: rotate(7deg); } 55% { transform: rotate(7deg); } }
|
|
||||||
@keyframes trek-pack { 0%, 50%, 100% { transform: rotate(0); } 25%, 75% { transform: rotate(-3deg); } }
|
|
||||||
@keyframes trek-trail { to { stroke-dashoffset: 8; } }
|
|
||||||
|
|
||||||
.trek { animation: trek-in 480ms cubic-bezier(.34, 1.4, .64, 1) both; transform-origin: 50% 100%; }
|
|
||||||
.trek-root { animation: trek-idle 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-body { animation: trek-breathe 3.8s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-shadow { animation: trek-shadow 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; opacity: .15; filter: blur(1px); }
|
|
||||||
/* eyes read as cutouts in the surface behind the mascot, so they stay visible on the monochrome body */
|
|
||||||
.trek-eye { fill: var(--m-bg); }
|
|
||||||
.trek-eyes { animation: trek-blink 5.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-pupils { animation: trek-look 7s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
/* body bounce — per scene */
|
|
||||||
.trek-bounce { transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-bounce--idle { animation: trek-hop 4.6s ease-in-out infinite; }
|
|
||||||
.trek-bounce--polls { animation: trek-nod 3s ease-in-out infinite; }
|
|
||||||
.trek-bounce--transport { animation: trek-sk-body 3.6s ease-in-out infinite; }
|
|
||||||
.trek-bounce--tours { animation: trek-walk 1.6s ease-in-out infinite; }
|
|
||||||
/* per-scene props */
|
|
||||||
.trek-board { animation: trek-sk-board 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 65%; }
|
|
||||||
.trek-wheel { animation: trek-roll 1.1s linear infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-flag { animation: trek-flag 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: 0% 50%; }
|
|
||||||
.trek-ticket { animation: trek-ticket 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-note { animation: trek-ticket 3.9s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-pencil { animation: trek-pencil 1.15s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-write { animation: trek-write 3.8s ease-in-out infinite; transform-box: fill-box; transform-origin: 0% 50%; }
|
|
||||||
.trek-bar { animation: trek-bar 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-dot { animation: trek-typing 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
|
|
||||||
.trek-suitcase { animation: trek-suitcase 1.5s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-handle { animation: trek-handle 1.5s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-pin { animation: trek-pin 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-chain { animation: trek-chain 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-link { animation: trek-link 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-globe { animation: trek-globe 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-coin { animation: trek-coin 2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
|
|
||||||
.trek-page { animation: trek-page 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 0% 50%; }
|
|
||||||
.trek-plane { animation: trek-plane 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-magnifier { animation: trek-magnifier 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-z { animation: trek-z 2.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-check { animation: trek-check 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
|
||||||
.trek-pole { animation: trek-pole 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0%; }
|
|
||||||
.trek-pack { animation: trek-pack 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 90% 10%; }
|
|
||||||
.trek-trail { animation: trek-trail .8s linear infinite; }
|
|
||||||
/* staggered starts for written lines / poll bars / Zzz */
|
|
||||||
.trek-d2, .trek-z2 { animation-delay: .5s; }
|
|
||||||
.trek-d3, .trek-z3 { animation-delay: 1s; }
|
|
||||||
|
|
||||||
/* Mobile range slider — the --m-* twin of the desktop .trek-range. */
|
/* Mobile range slider — the --m-* twin of the desktop .trek-range. */
|
||||||
.m-range {
|
.m-range {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
@@ -514,6 +366,144 @@ html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-
|
|||||||
:root[dir='rtl'] {
|
:root[dir='rtl'] {
|
||||||
--m-vt-dir: -1;
|
--m-vt-dir: -1;
|
||||||
}
|
}
|
||||||
|
.m-labelled-dock {
|
||||||
|
box-shadow: 0 8px 26px -18px var(--m-dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-glass-elevated {
|
||||||
|
box-shadow:
|
||||||
|
0 0 7px color-mix(in srgb, var(--m-dim) 12%, transparent),
|
||||||
|
0 3px 8px -4px color-mix(in srgb, var(--m-dim) 22%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-glass-badge {
|
||||||
|
box-shadow: 0 1px 3px color-mix(in srgb, var(--m-dim) 8%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-roadtrip-sheet[data-m-sheet] {
|
||||||
|
box-shadow: 0 18px 52px -25px var(--m-dim), inset 0 1px 0 var(--m-gbr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
|
||||||
|
.m-root .m-roadtrip-sheet[data-m-sheet] {
|
||||||
|
background: linear-gradient(
|
||||||
|
155deg,
|
||||||
|
color-mix(in srgb, var(--m-sheetop) 94%, transparent),
|
||||||
|
color-mix(in srgb, var(--m-sheetop) 87%, transparent)
|
||||||
|
);
|
||||||
|
backdrop-filter: blur(28px) saturate(1.25);
|
||||||
|
-webkit-backdrop-filter: blur(28px) saturate(1.25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-transparency: reduce) {
|
||||||
|
.m-root .m-roadtrip-sheet[data-m-sheet] {
|
||||||
|
background: var(--m-sheetop);
|
||||||
|
backdrop-filter: none;
|
||||||
|
-webkit-backdrop-filter: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-roadtrip-field {
|
||||||
|
--m-field-height: 40px;
|
||||||
|
--m-field-radius: 12px;
|
||||||
|
--m-field-surface: var(--m-sheetop);
|
||||||
|
--text-primary: var(--m-ink);
|
||||||
|
--text-faint: var(--m-muted);
|
||||||
|
width: 7rem;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-roadtrip-field input {
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.3;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-roadtrip-field input::placeholder {
|
||||||
|
color: var(--m-muted);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-roadtrip-field [data-field-trigger]:focus-within {
|
||||||
|
box-shadow: 0 0 0 1px var(--m-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-roadtrip-options {
|
||||||
|
background: var(--m-sheetop);
|
||||||
|
border: 1px solid var(--m-rowbr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-roadtrip-options [role="tab"] {
|
||||||
|
min-height: 34px;
|
||||||
|
font-size: calc(13px * var(--fs-scale-body, 1));
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-roadtrip-heading:focus-visible {
|
||||||
|
border-radius: 9999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-roadtrip-stop-number {
|
||||||
|
box-shadow: 0 0 8px color-mix(in srgb, var(--m-dim) 24%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-round-control:focus-visible {
|
||||||
|
border-radius: 50%;
|
||||||
|
outline: 2px solid currentColor;
|
||||||
|
outline-offset: -3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-dock-item {
|
||||||
|
display: grid;
|
||||||
|
justify-items: center;
|
||||||
|
align-content: center;
|
||||||
|
gap: 2px;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 44px;
|
||||||
|
min-height: 54px;
|
||||||
|
color: var(--m-muted);
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-dock-item:focus-visible {
|
||||||
|
outline: 2px solid var(--m-act);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-dock-item:active,
|
||||||
|
.m-dock-item[aria-expanded='true'] {
|
||||||
|
background: var(--m-ic);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-dock-symbol {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 36px;
|
||||||
|
height: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-dock-item[aria-current='page'] {
|
||||||
|
background: var(--m-act);
|
||||||
|
color: var(--m-actfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-dock-item[aria-current='page']:focus-visible {
|
||||||
|
outline-color: var(--m-actfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-dock-label {
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-size: calc(10px * var(--fs-scale-caption, 1));
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
.m-dock-vt {
|
.m-dock-vt {
|
||||||
view-transition-name: m-dock;
|
view-transition-name: m-dock;
|
||||||
}
|
}
|
||||||
@@ -577,16 +567,34 @@ html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-
|
|||||||
sheets' own fields: a 42 px round field on the field surface. They style
|
sheets' own fields: a 42 px round field on the field surface. They style
|
||||||
themselves inline for the desktop, hence the !important. */
|
themselves inline for the desktop, hence the !important. */
|
||||||
.m-root [data-field-trigger] {
|
.m-root [data-field-trigger] {
|
||||||
min-height: 42px;
|
min-height: var(--m-field-height, 42px);
|
||||||
border-radius: 9999px !important;
|
border-radius: var(--m-field-radius, 9999px) !important;
|
||||||
border: 1px solid var(--m-rowbr) !important;
|
border: 1px solid var(--m-rowbr) !important;
|
||||||
background: var(--m-ic) !important;
|
background: var(--m-field-surface, var(--m-ic)) !important;
|
||||||
}
|
}
|
||||||
.m-root button[data-field-trigger],
|
.m-root button[data-field-trigger],
|
||||||
.m-root [data-field-trigger='pad'] {
|
.m-root [data-field-trigger='pad'] {
|
||||||
padding-inline: 14px !important;
|
padding-inline: 14px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-fs-body {
|
||||||
|
--m-field-height: 44px;
|
||||||
|
--m-field-radius: 12px;
|
||||||
|
--m-field-surface: var(--m-sheetop);
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root [data-m-sheet]:has(> [data-entry-form]) {
|
||||||
|
background: color-mix(in srgb, var(--m-sheetop) 97%, var(--m-ink));
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-form-label {
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-root .m-fs-body [data-field-trigger]:focus-within {
|
||||||
|
box-shadow: inset 0 0 0 1px var(--m-act);
|
||||||
|
}
|
||||||
|
|
||||||
/* ── The page column on a wide window ───────────────────────────────────────
|
/* ── The page column on a wide window ───────────────────────────────────────
|
||||||
Fixed bars span the page, not the window: they start after the navigation
|
Fixed bars span the page, not the window: they start after the navigation
|
||||||
rail (--m-rail-w, 0 on a phone, so these are the phone's insets there). */
|
rail (--m-rail-w, 0 on a phone, so these are the phone's insets there). */
|
||||||
@@ -891,6 +899,9 @@ html:has(.m-shell) ::-webkit-scrollbar {
|
|||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
|
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
|
||||||
}
|
}
|
||||||
|
.m-form-sheet > .m-inspector-actions {
|
||||||
|
grid-row: 2;
|
||||||
|
}
|
||||||
.m-form-sheet:has(> .m-fs-foot) > .m-fs-head .m-fs-close {
|
.m-form-sheet:has(> .m-fs-foot) > .m-fs-head .m-fs-close {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -900,7 +911,7 @@ html:has(.m-shell) ::-webkit-scrollbar {
|
|||||||
button and the trailing button draws its segments tighter first
|
button and the trailing button draws its segments tighter first
|
||||||
(MTripShellParts GlassSegment), and scrolls only where that is not enough. */
|
(MTripShellParts GlassSegment), and scrolls only where that is not enough. */
|
||||||
.m-seg[data-tight='true'] > * {
|
.m-seg[data-tight='true'] > * {
|
||||||
padding-inline: 10px;
|
padding-inline: var(--m-seg-tight-padding, 10px);
|
||||||
}
|
}
|
||||||
/* A one-line Markdown caption (MarkdownText clamp: an address, a note in a
|
/* A one-line Markdown caption (MarkdownText clamp: an address, a note in a
|
||||||
row) ends in an ellipsis. The clamp sits on the wrapper, but the text is in
|
row) ends in an ellipsis. The clamp sits on the wrapper, but the text is in
|
||||||
|
|||||||
@@ -0,0 +1,602 @@
|
|||||||
|
/* ── TREK mascot (empty-state) — logo-as-body character, per-scene props ───── */
|
||||||
|
@keyframes trek-idle {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0) rotate(-1.1deg);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(-2px) rotate(1.1deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-breathe {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: scale(1.012, 1.024);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-shadow {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: scaleX(1);
|
||||||
|
opacity: 0.15;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: scaleX(1.05);
|
||||||
|
opacity: 0.17;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* body hop, occasional: long rest, then anticipation squash → airborne → land → settle */
|
||||||
|
@keyframes trek-hop {
|
||||||
|
0%,
|
||||||
|
74%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0) scale(1, 1);
|
||||||
|
}
|
||||||
|
79% {
|
||||||
|
transform: translateY(1px) scale(1.05, 0.92);
|
||||||
|
}
|
||||||
|
87% {
|
||||||
|
transform: translateY(-10px) scale(0.95, 1.07);
|
||||||
|
}
|
||||||
|
94% {
|
||||||
|
transform: translateY(0) scale(1.07, 0.93);
|
||||||
|
}
|
||||||
|
98% {
|
||||||
|
transform: translateY(0) scale(0.99, 1.01);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* body nod — a pleased look left-and-right, e.g. cheering the poll results */
|
||||||
|
@keyframes trek-nod {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0) rotate(0);
|
||||||
|
}
|
||||||
|
25% {
|
||||||
|
transform: translateY(-2px) rotate(-4deg);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(0) rotate(0);
|
||||||
|
}
|
||||||
|
75% {
|
||||||
|
transform: translateY(-2px) rotate(4deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* slow blink: eyes squeeze shut for a couple of frames each cycle */
|
||||||
|
@keyframes trek-blink {
|
||||||
|
0%,
|
||||||
|
90%,
|
||||||
|
100% {
|
||||||
|
transform: scaleY(1);
|
||||||
|
}
|
||||||
|
94%,
|
||||||
|
97% {
|
||||||
|
transform: scaleY(0.12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* entrance / poke-to-react pop-in (plays on mount and on each remount/tap) */
|
||||||
|
@keyframes trek-in {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(7px) scale(0.85);
|
||||||
|
}
|
||||||
|
60% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* pupils glancing around — centred most of the time, occasional look down/side */
|
||||||
|
@keyframes trek-look {
|
||||||
|
0%,
|
||||||
|
34%,
|
||||||
|
100% {
|
||||||
|
transform: translate(0, 0);
|
||||||
|
}
|
||||||
|
42%,
|
||||||
|
52% {
|
||||||
|
transform: translate(0, 0.9px);
|
||||||
|
}
|
||||||
|
64%,
|
||||||
|
72% {
|
||||||
|
transform: translate(0.9px, 0.1px);
|
||||||
|
}
|
||||||
|
84%,
|
||||||
|
90% {
|
||||||
|
transform: translate(-0.8px, 0.2px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* wheels rolling in place */
|
||||||
|
@keyframes trek-roll {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* skateboard ollie — body and board pop off the ground together, now and then */
|
||||||
|
@keyframes trek-sk-body {
|
||||||
|
0%,
|
||||||
|
68%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0) scale(1, 1);
|
||||||
|
}
|
||||||
|
73% {
|
||||||
|
transform: translateY(1.5px) scale(1.04, 0.95);
|
||||||
|
}
|
||||||
|
84% {
|
||||||
|
transform: translateY(-9px) scale(0.97, 1.05);
|
||||||
|
}
|
||||||
|
92% {
|
||||||
|
transform: translateY(0) scale(1.05, 0.95);
|
||||||
|
}
|
||||||
|
96% {
|
||||||
|
transform: translateY(0) scale(1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-sk-board {
|
||||||
|
0%,
|
||||||
|
68%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0) rotate(0);
|
||||||
|
}
|
||||||
|
73% {
|
||||||
|
transform: translateY(0) rotate(-6deg);
|
||||||
|
}
|
||||||
|
84% {
|
||||||
|
transform: translateY(-8px) rotate(7deg);
|
||||||
|
}
|
||||||
|
90% {
|
||||||
|
transform: translateY(-3px) rotate(-3deg);
|
||||||
|
}
|
||||||
|
95% {
|
||||||
|
transform: translateY(0) rotate(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* guide pennant fluttering — pivots at the pole */
|
||||||
|
@keyframes trek-flag {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: skewY(0) scaleX(1);
|
||||||
|
}
|
||||||
|
30% {
|
||||||
|
transform: skewY(-7deg) scaleX(0.96);
|
||||||
|
}
|
||||||
|
60% {
|
||||||
|
transform: skewY(6deg) scaleX(1.03);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* poll bars staying up, gently rising and settling like live tallies */
|
||||||
|
@keyframes trek-bar {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: scaleY(0.78);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: scaleY(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-typing {
|
||||||
|
0%,
|
||||||
|
70%,
|
||||||
|
100% {
|
||||||
|
transform: scale(0.5);
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
35% {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* card / note rocking gently */
|
||||||
|
@keyframes trek-ticket {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: rotate(-2.5deg);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: rotate(2.5deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* a line being written: draws in from the left, holds, then a fresh pass */
|
||||||
|
@keyframes trek-write {
|
||||||
|
0% {
|
||||||
|
transform: scaleX(0);
|
||||||
|
}
|
||||||
|
30%,
|
||||||
|
82% {
|
||||||
|
transform: scaleX(1);
|
||||||
|
}
|
||||||
|
92%,
|
||||||
|
100% {
|
||||||
|
transform: scaleX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* pencil scribbling as the lines appear */
|
||||||
|
@keyframes trek-pencil {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translate(0, 0) rotate(0);
|
||||||
|
}
|
||||||
|
20% {
|
||||||
|
transform: translate(-1.5px, 1.5px) rotate(-4deg);
|
||||||
|
}
|
||||||
|
45% {
|
||||||
|
transform: translate(1.5px, -0.5px) rotate(3deg);
|
||||||
|
}
|
||||||
|
70% {
|
||||||
|
transform: translate(-1px, 1px) rotate(-2deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* suitcase rocking on its wheels, restless to get going */
|
||||||
|
@keyframes trek-suitcase {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: rotate(-2.5deg);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: rotate(2.5deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* suitcase handle telescoping up and down */
|
||||||
|
@keyframes trek-handle {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* collections map pin bobbing */
|
||||||
|
@keyframes trek-pin {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(-4px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Chain: the pair sways, and the near link slides out along its own axis and
|
||||||
|
clicks back in. Moving only the near one keeps the joint readable at 88px. */
|
||||||
|
@keyframes trek-chain {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: rotate(-6deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-link {
|
||||||
|
0%,
|
||||||
|
62%,
|
||||||
|
100% {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
30% {
|
||||||
|
transform: translateX(2.6px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* atlas globe meridian drifting to fake a slow spin */
|
||||||
|
@keyframes trek-globe {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateX(-2px);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateX(2px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* costs top coin bouncing on */
|
||||||
|
@keyframes trek-coin {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
30% {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
}
|
||||||
|
55% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
70% {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
84% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* journey page turning over the spine */
|
||||||
|
@keyframes trek-page {
|
||||||
|
0%,
|
||||||
|
55%,
|
||||||
|
100% {
|
||||||
|
transform: scaleX(1);
|
||||||
|
}
|
||||||
|
78% {
|
||||||
|
transform: scaleX(-0.9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* dashboard paper plane bobbing in flight */
|
||||||
|
@keyframes trek-plane {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translate(0, 0) rotate(0);
|
||||||
|
}
|
||||||
|
25% {
|
||||||
|
transform: translate(-1px, -2px) rotate(-4deg);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translate(0, 0) rotate(0);
|
||||||
|
}
|
||||||
|
75% {
|
||||||
|
transform: translate(1px, 2px) rotate(4deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* notifications Zzz drifting up and fading */
|
||||||
|
@keyframes trek-z {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate(0, 4px) scale(0.7);
|
||||||
|
}
|
||||||
|
30% {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate(3px, -8px) scale(1.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* search magnifier scanning */
|
||||||
|
@keyframes trek-magnifier {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: translateX(-3px) rotate(-3deg);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateX(3px) rotate(3deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* to-do checkmark ticking on, holding, then resetting */
|
||||||
|
@keyframes trek-check {
|
||||||
|
0%,
|
||||||
|
8% {
|
||||||
|
transform: scale(0);
|
||||||
|
}
|
||||||
|
22% {
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
32%,
|
||||||
|
88% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
96%,
|
||||||
|
100% {
|
||||||
|
transform: scale(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* tours: a walking step, the pole swinging forward and planting, the pack riding along */
|
||||||
|
@keyframes trek-walk {
|
||||||
|
0%,
|
||||||
|
50%,
|
||||||
|
100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
25%,
|
||||||
|
75% {
|
||||||
|
transform: translateY(-1.6px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-pole {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
transform: rotate(-9deg);
|
||||||
|
}
|
||||||
|
45% {
|
||||||
|
transform: rotate(7deg);
|
||||||
|
}
|
||||||
|
55% {
|
||||||
|
transform: rotate(7deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-pack {
|
||||||
|
0%,
|
||||||
|
50%,
|
||||||
|
100% {
|
||||||
|
transform: rotate(0);
|
||||||
|
}
|
||||||
|
25%,
|
||||||
|
75% {
|
||||||
|
transform: rotate(-3deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes trek-trail {
|
||||||
|
to {
|
||||||
|
stroke-dashoffset: 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.trek {
|
||||||
|
animation: trek-in 480ms cubic-bezier(0.34, 1.4, 0.64, 1) both;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-root {
|
||||||
|
animation: trek-idle 3.4s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-body {
|
||||||
|
animation: trek-breathe 3.8s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-shadow {
|
||||||
|
animation: trek-shadow 3.4s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 50%;
|
||||||
|
opacity: 0.15;
|
||||||
|
filter: blur(1px);
|
||||||
|
}
|
||||||
|
/* eyes read as cutouts in the surface behind the mascot, so they stay visible on the monochrome body */
|
||||||
|
.trek-eye {
|
||||||
|
fill: var(--m-bg);
|
||||||
|
}
|
||||||
|
.trek-eyes {
|
||||||
|
animation: trek-blink 5.2s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-pupils {
|
||||||
|
animation: trek-look 7s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
/* body bounce — per scene */
|
||||||
|
.trek-bounce {
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-bounce--idle {
|
||||||
|
animation: trek-hop 4.6s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
.trek-bounce--polls {
|
||||||
|
animation: trek-nod 3s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
.trek-bounce--transport {
|
||||||
|
animation: trek-sk-body 3.6s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
.trek-bounce--tours {
|
||||||
|
animation: trek-walk 1.6s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
/* per-scene props */
|
||||||
|
.trek-board {
|
||||||
|
animation: trek-sk-board 3.6s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 65%;
|
||||||
|
}
|
||||||
|
.trek-wheel {
|
||||||
|
animation: trek-roll 1.1s linear infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-flag {
|
||||||
|
animation: trek-flag 1.8s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 0% 50%;
|
||||||
|
}
|
||||||
|
.trek-ticket {
|
||||||
|
animation: trek-ticket 3.6s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-note {
|
||||||
|
animation: trek-ticket 3.9s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-pencil {
|
||||||
|
animation: trek-pencil 1.15s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-write {
|
||||||
|
animation: trek-write 3.8s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 0% 50%;
|
||||||
|
}
|
||||||
|
.trek-bar {
|
||||||
|
animation: trek-bar 2.6s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-dot {
|
||||||
|
animation: trek-typing 1.4s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 50%;
|
||||||
|
}
|
||||||
|
.trek-suitcase {
|
||||||
|
animation: trek-suitcase 1.5s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-handle {
|
||||||
|
animation: trek-handle 1.5s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-pin {
|
||||||
|
animation: trek-pin 2.2s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-chain {
|
||||||
|
animation: trek-chain 3s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-link {
|
||||||
|
animation: trek-link 2.4s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-globe {
|
||||||
|
animation: trek-globe 3s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-coin {
|
||||||
|
animation: trek-coin 2s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 100%;
|
||||||
|
}
|
||||||
|
.trek-page {
|
||||||
|
animation: trek-page 3.4s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 0% 50%;
|
||||||
|
}
|
||||||
|
.trek-plane {
|
||||||
|
animation: trek-plane 3s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-magnifier {
|
||||||
|
animation: trek-magnifier 2.4s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-z {
|
||||||
|
animation: trek-z 2.8s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-check {
|
||||||
|
animation: trek-check 3s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
.trek-pole {
|
||||||
|
animation: trek-pole 1.6s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 50% 0%;
|
||||||
|
}
|
||||||
|
.trek-pack {
|
||||||
|
animation: trek-pack 1.6s ease-in-out infinite;
|
||||||
|
transform-box: fill-box;
|
||||||
|
transform-origin: 90% 10%;
|
||||||
|
}
|
||||||
|
.trek-trail {
|
||||||
|
animation: trek-trail 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
/* staggered starts for written lines / poll bars / Zzz */
|
||||||
|
.trek-d2,
|
||||||
|
.trek-z2 {
|
||||||
|
animation-delay: 0.5s;
|
||||||
|
}
|
||||||
|
.trek-d3,
|
||||||
|
.trek-z3 {
|
||||||
|
animation-delay: 1s;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
.m-form-sheet [data-select-has-badge] {
|
||||||
|
display: grid !important;
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto;
|
||||||
|
column-gap: 6px !important;
|
||||||
|
row-gap: 2px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-sheet [data-select-has-badge] [data-select-label] {
|
||||||
|
grid-column: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-sheet [data-select-has-badge] [data-select-badge] {
|
||||||
|
grid-column: 1;
|
||||||
|
grid-row: 2;
|
||||||
|
padding: 0 !important;
|
||||||
|
background: transparent !important;
|
||||||
|
color: var(--m-muted) !important;
|
||||||
|
font-weight: 500 !important;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-sheet [data-select-has-badge] > svg:last-child {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 1 / 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-select-menu {
|
||||||
|
border-color: var(--m-rowbr) !important;
|
||||||
|
border-radius: 14px !important;
|
||||||
|
background: var(--m-sheetop) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-select-menu [data-select-option] {
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 7px 10px !important;
|
||||||
|
border-radius: 10px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-select-menu [data-select-option][aria-pressed='true'] {
|
||||||
|
background: var(--m-ic) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-select-menu [data-select-option] [data-select-label] {
|
||||||
|
min-width: 0;
|
||||||
|
white-space: normal !important;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-form-select-menu [data-select-option] [data-select-badge] {
|
||||||
|
max-width: 55%;
|
||||||
|
white-space: normal;
|
||||||
|
background: var(--m-ic) !important;
|
||||||
|
color: var(--m-muted) !important;
|
||||||
|
}
|
||||||
@@ -1,20 +1,17 @@
|
|||||||
import { ChevronRight, MapPin, Star, Trash2 } from 'lucide-react'
|
import { ChevronRight, MapPin, Star, Trash2 } from 'lucide-react'
|
||||||
import type { LucideIcon } from 'lucide-react'
|
import type { LucideIcon } from 'lucide-react'
|
||||||
|
import CountryFlag from '../../../components/shared/CountryFlag'
|
||||||
import MSheet from '../../components/MSheet'
|
import MSheet from '../../components/MSheet'
|
||||||
|
import {
|
||||||
|
FIELD_CLS, FORM_LABEL_CLS, FormSheetBody, FormSheetFooter, FormSheetHeader, FormSheetSection,
|
||||||
|
} from '../trip/sheets/PlSheetChrome'
|
||||||
|
import { SHEET_DANGER, SHEET_SECONDARY } from '../trip/sheets/MTripSheetUi'
|
||||||
import { type AtlasCountryActionsOptions, useAtlasCountryActions } from '../../../pages/atlas/useAtlasCountryActions'
|
import { type AtlasCountryActionsOptions, useAtlasCountryActions } from '../../../pages/atlas/useAtlasCountryActions'
|
||||||
|
|
||||||
const markTint = 'bg-[rgba(47,163,122,.16)] text-[color:var(--m-st-confirmed)]' // theme-lint-disable — fixed tint from the design's option rows
|
const markTint = 'bg-[rgba(47,163,122,.16)] text-[color:var(--m-st-confirmed)]' // theme-lint-disable — fixed tint from the design's option rows
|
||||||
const bucketTint = 'bg-[rgba(232,161,58,.16)] text-[color:var(--m-st-pending)]' // theme-lint-disable — fixed tint from the design's option rows
|
const bucketTint = 'bg-[rgba(232,161,58,.16)] text-[color:var(--m-st-pending)]' // theme-lint-disable — fixed tint from the design's option rows
|
||||||
const removeTint = 'bg-[color:color-mix(in_srgb,var(--m-st-danger)_16%,transparent)] text-[color:var(--m-st-danger)]'
|
const removeTint = 'bg-[color:color-mix(in_srgb,var(--m-st-danger)_16%,transparent)] text-[color:var(--m-st-danger)]'
|
||||||
|
|
||||||
const btnBase = 'flex-1 rounded-full py-[11px] text-[0.8125rem] font-bold'
|
|
||||||
const cancelBtn = `${btnBase} bg-[color:var(--m-ic)] text-m-ink`
|
|
||||||
const dangerBtn = `${btnBase} bg-[color:var(--m-st-danger)] text-white`
|
|
||||||
const actBtn = `${btnBase} bg-m-act text-m-actfg`
|
|
||||||
|
|
||||||
const inputCls =
|
|
||||||
'mt-2 w-full rounded-[14px] border border-[color:var(--m-inbr)] bg-[color:var(--m-inner)] px-[14px] py-[11px] text-[0.84375rem] font-medium text-m-ink outline-none'
|
|
||||||
|
|
||||||
interface OptionRowProps {
|
interface OptionRowProps {
|
||||||
icon: LucideIcon
|
icon: LucideIcon
|
||||||
tint: string
|
tint: string
|
||||||
@@ -28,16 +25,16 @@ function OptionRow({ icon: Icon, tint, title, hint, onClick }: OptionRowProps) {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className="flex w-full items-center gap-[13px] rounded-[18px] bg-[color:var(--m-ic)] px-4 py-[14px] text-start"
|
className="flex min-h-12 w-full items-center gap-3 px-3 py-2.5 text-start active:bg-m-rowbr"
|
||||||
>
|
>
|
||||||
<span className={`flex h-10 w-10 flex-none items-center justify-center rounded-xl ${tint}`}>
|
<span className={`grid size-8 flex-none place-items-center rounded-lg ${tint}`}>
|
||||||
<Icon size={20} strokeWidth={2} />
|
<Icon size={16} aria-hidden />
|
||||||
</span>
|
</span>
|
||||||
<span className="min-w-0 flex-1">
|
<span className="min-w-0 flex-1">
|
||||||
<span className="block text-[0.9375rem] font-extrabold text-m-ink">{title}</span>
|
<span className="block text-control font-semibold text-m-ink">{title}</span>
|
||||||
<span className="mt-[1px] block font-geist text-[0.6875rem] text-m-muted">{hint}</span>
|
<span className="mt-0.5 block text-caption text-m-muted">{hint}</span>
|
||||||
</span>
|
</span>
|
||||||
<ChevronRight size={17} strokeWidth={2} className="flex-none text-m-faint" />
|
<ChevronRight size={16} className="flex-none text-m-muted rtl:rotate-180" aria-hidden />
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -58,128 +55,85 @@ export default function MAtlasCountryPopup({ atlas }: MAtlasCountryPopupProps) {
|
|||||||
useAtlasCountryActions(atlas)
|
useAtlasCountryActions(atlas)
|
||||||
|
|
||||||
const a = confirmAction
|
const a = confirmAction
|
||||||
|
const close = () => setConfirmAction(null)
|
||||||
|
const choosingRegion = a?.type === 'choose-region'
|
||||||
|
const unmarkingRegion = a?.type === 'unmark-region'
|
||||||
|
const unmarking = a?.type === 'unmark' || unmarkingRegion
|
||||||
|
const confirming = a?.type === 'mark' || unmarking
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MSheet open={!!a} onClose={() => setConfirmAction(null)} variant="card" ariaLabel={a?.name}>
|
<MSheet open={!!a} onClose={close} variant="card" form ariaLabel={a?.name}>
|
||||||
{a && (
|
{a && (
|
||||||
<div className="flex flex-col gap-2 p-5">
|
<>
|
||||||
<div className="flex flex-col items-center pb-2 text-center">
|
<FormSheetHeader
|
||||||
{a.code.length === 2 ? (
|
leading={
|
||||||
<img
|
<span className="grid size-10 flex-none place-items-center rounded-[13px] bg-m-ic" aria-hidden>
|
||||||
src={`https://flagcdn.com/w80/${a.code.toLowerCase()}.png`}
|
{a.code.length === 2 ? <CountryFlag code={a.code} size={24} /> : <MapPin size={18} />}
|
||||||
alt=""
|
|
||||||
className="h-[34px] w-12 rounded-[6px] object-cover shadow-[0_1px_3px_rgba(0,0,0,.25)]"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
// flagcdn only serves alpha-2, so anything else gets a neutral placeholder.
|
|
||||||
<span className="flex h-[34px] w-12 items-center justify-center rounded-[6px] bg-[color:var(--m-ic)] text-m-faint">
|
|
||||||
<MapPin size={18} strokeWidth={2} />
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
}
|
||||||
<div className="mt-3 text-[1.0625rem] font-extrabold text-m-ink">{a.name}</div>
|
title={a.name}
|
||||||
{a.countryName && (a.type === 'choose-region' || a.type === 'unmark-region') && (
|
subtitle={choosingRegion || unmarkingRegion ? a.countryName : undefined}
|
||||||
<div className="mt-[2px] font-geist text-[0.6875rem] text-m-muted">{a.countryName}</div>
|
onClose={close}
|
||||||
)}
|
closeLabel={t('common.close')}
|
||||||
</div>
|
/>
|
||||||
|
<FormSheetBody>
|
||||||
{a.type === 'choose' && (
|
{(a.type === 'choose' || choosingRegion) && (
|
||||||
<>
|
<div className="divide-y divide-m-rowbr overflow-hidden rounded-[14px] bg-m-ic">
|
||||||
<OptionRow icon={MapPin} tint={markTint} title={t('atlas.markVisited')} hint={t('atlas.markVisitedHint')} onClick={markCountry} />
|
|
||||||
<OptionRow
|
|
||||||
icon={Star}
|
|
||||||
tint={bucketTint}
|
|
||||||
title={t('atlas.addToBucket')}
|
|
||||||
hint={t('atlas.addToBucketHint')}
|
|
||||||
onClick={() => setConfirmAction({ ...a, type: 'bucket' })}
|
|
||||||
/>
|
|
||||||
{onWishlist && (
|
|
||||||
<OptionRow
|
<OptionRow
|
||||||
icon={Trash2}
|
icon={MapPin} tint={markTint}
|
||||||
tint={removeTint}
|
title={t('atlas.markVisited')}
|
||||||
title={t('atlas.removeFromBucket')}
|
hint={t(choosingRegion ? 'atlas.markRegionVisitedHint' : 'atlas.markVisitedHint')}
|
||||||
hint={t('atlas.removeFromBucketHint')}
|
onClick={choosingRegion ? () => void markRegion(true) : () => void markCountry()}
|
||||||
onClick={removeBucket}
|
|
||||||
/>
|
/>
|
||||||
)}
|
<OptionRow
|
||||||
</>
|
icon={Star} tint={bucketTint}
|
||||||
)}
|
title={t('atlas.addToBucket')} hint={t('atlas.addToBucketHint')}
|
||||||
|
onClick={() => setConfirmAction({ ...a, type: 'bucket' })}
|
||||||
{a.type === 'choose-region' && (
|
/>
|
||||||
<>
|
{!choosingRegion && onWishlist && (
|
||||||
<OptionRow icon={MapPin} tint={markTint} title={t('atlas.markVisited')} hint={t('atlas.markRegionVisitedHint')} onClick={() => markRegion(true)} />
|
<OptionRow
|
||||||
<OptionRow
|
icon={Trash2} tint={removeTint}
|
||||||
icon={Star}
|
title={t('atlas.removeFromBucket')} hint={t('atlas.removeFromBucketHint')}
|
||||||
tint={bucketTint}
|
onClick={() => void removeBucket()}
|
||||||
title={t('atlas.addToBucket')}
|
/>
|
||||||
hint={t('atlas.addToBucketHint')}
|
)}
|
||||||
onClick={() => setConfirmAction({ ...a, type: 'bucket' })}
|
</div>
|
||||||
/>
|
)}
|
||||||
</>
|
{confirming && (
|
||||||
)}
|
<FormSheetSection>
|
||||||
|
<p className="text-control text-m-muted">
|
||||||
|
{t(unmarkingRegion ? 'atlas.confirmUnmarkRegion' : unmarking ? 'atlas.confirmUnmark' : 'atlas.confirmMark')}
|
||||||
|
</p>
|
||||||
|
</FormSheetSection>
|
||||||
|
)}
|
||||||
|
{a.type === 'bucket' && (
|
||||||
|
<FormSheetSection>
|
||||||
|
<label className="block space-y-1.5">
|
||||||
|
<span className={FORM_LABEL_CLS}>{t('atlas.bucketWhen')}</span>
|
||||||
|
<input type="month" value={bucketDate} onChange={(e) => setBucketDate(e.target.value)} className={FIELD_CLS} />
|
||||||
|
</label>
|
||||||
|
</FormSheetSection>
|
||||||
|
)}
|
||||||
|
</FormSheetBody>
|
||||||
{a.type === 'mark' && (
|
{a.type === 'mark' && (
|
||||||
<>
|
<FormSheetFooter onCancel={close} cancelLabel={t('common.cancel')}
|
||||||
<p className="pb-2 text-center text-[0.8125rem] text-m-muted">{t('atlas.confirmMark')}</p>
|
onSubmit={() => void executeConfirmAction()} submitLabel={t('atlas.markVisited')} />
|
||||||
<div className="flex gap-2">
|
|
||||||
<button type="button" onClick={() => setConfirmAction(null)} className={cancelBtn}>
|
|
||||||
{t('common.cancel')}
|
|
||||||
</button>
|
|
||||||
<button type="button" onClick={executeConfirmAction} className={actBtn}>
|
|
||||||
{t('atlas.markVisited')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
{unmarking && (
|
||||||
{a.type === 'unmark' && (
|
<div className="m-fs-foot flex flex-none flex-wrap justify-end gap-2 border-t border-m-rowbr px-[18px] pb-4 pt-3">
|
||||||
<>
|
<button type="button" onClick={close} className={SHEET_SECONDARY}>{t('common.cancel')}</button>
|
||||||
<p className="pb-2 text-center text-[0.8125rem] text-m-muted">{t('atlas.confirmUnmark')}</p>
|
<button type="button" onClick={() => void (unmarkingRegion ? unmarkRegion() : executeConfirmAction())} className={SHEET_DANGER}>
|
||||||
<div className="flex gap-2">
|
{t('atlas.unmark')}
|
||||||
<button type="button" onClick={() => setConfirmAction(null)} className={cancelBtn}>
|
</button>
|
||||||
{t('common.cancel')}
|
</div>
|
||||||
</button>
|
|
||||||
<button type="button" onClick={executeConfirmAction} className={dangerBtn}>
|
|
||||||
{t('atlas.unmark')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{a.type === 'unmark-region' && (
|
|
||||||
<>
|
|
||||||
<p className="pb-2 text-center text-[0.8125rem] text-m-muted">{t('atlas.confirmUnmarkRegion')}</p>
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<button type="button" onClick={() => setConfirmAction(null)} className={cancelBtn}>
|
|
||||||
{t('common.cancel')}
|
|
||||||
</button>
|
|
||||||
<button type="button" onClick={unmarkRegion} className={dangerBtn}>
|
|
||||||
{t('atlas.unmark')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{a.type === 'bucket' && (
|
{a.type === 'bucket' && (
|
||||||
<>
|
<FormSheetFooter
|
||||||
<label className="block text-start">
|
onCancel={() => setConfirmAction({ ...a, type: a.regionCode ? 'choose-region' : 'choose' })}
|
||||||
<span className="font-geist text-[0.6875rem] font-bold text-m-muted">{t('atlas.bucketWhen')}</span>
|
cancelLabel={t('common.back')} onSubmit={() => void addBucketForDate()} submitLabel={t('atlas.addToBucket')}
|
||||||
<input type="month" value={bucketDate} onChange={(e) => setBucketDate(e.target.value)} className={inputCls} />
|
/>
|
||||||
</label>
|
|
||||||
<div className="mt-2 flex gap-2">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setConfirmAction({ ...a, type: a.regionCode ? 'choose-region' : 'choose' })}
|
|
||||||
className={cancelBtn}
|
|
||||||
>
|
|
||||||
{t('common.back')}
|
|
||||||
</button>
|
|
||||||
<button type="button" onClick={addBucketForDate} className={actBtn}>
|
|
||||||
{t('atlas.addToBucket')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</>
|
||||||
)}
|
)}
|
||||||
</MSheet>
|
</MSheet>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { Briefcase, CalendarClock, X } from 'lucide-react';
|
import { Briefcase, CalendarClock } from 'lucide-react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useNavigate } from 'react-router';
|
import { useNavigate } from 'react-router';
|
||||||
import AtlasCountryPlaces from '../../../components/Atlas/AtlasCountryPlaces';
|
import AtlasCountryPlaces from '../../../components/Atlas/AtlasCountryPlaces';
|
||||||
import CountryFlag from '../../../components/shared/CountryFlag';
|
import CountryFlag from '../../../components/shared/CountryFlag';
|
||||||
import { countryStatus } from '../../../pages/atlas/atlasModel';
|
import { countryStatus } from '../../../pages/atlas/atlasModel';
|
||||||
import type { AtlasGlobeState } from '../../../pages/atlas/useAtlasGlobe';
|
import type { AtlasGlobeState } from '../../../pages/atlas/useAtlasGlobe';
|
||||||
import MIconBtn from '../../components/MIconBtn';
|
|
||||||
import MProgress from '../../components/MProgress';
|
import MProgress from '../../components/MProgress';
|
||||||
import MSheet from '../../components/MSheet';
|
import MSheet from '../../components/MSheet';
|
||||||
|
import { FormSheetBody, FormSheetHeader, FormSheetSection } from '../trip/sheets/PlSheetChrome';
|
||||||
import MAtlasCountryPopup from './MAtlasCountryPopup';
|
import MAtlasCountryPopup from './MAtlasCountryPopup';
|
||||||
import { M_CARD } from './hub/mHubKit';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The globe's country and region sheets on the phone: the action card (mark,
|
* The globe's country and region sheets on the phone: the action card (mark,
|
||||||
@@ -39,6 +38,7 @@ export default function MAtlasCountrySheets({ s }: { s: AtlasGlobeState }): Reac
|
|||||||
open={!!s.detail}
|
open={!!s.detail}
|
||||||
onClose={s.closeDialogs}
|
onClose={s.closeDialogs}
|
||||||
variant="bottom"
|
variant="bottom"
|
||||||
|
form
|
||||||
ariaLabel={s.detail ? s.resolveName(s.detail.a2) : ''}
|
ariaLabel={s.detail ? s.resolveName(s.detail.a2) : ''}
|
||||||
>
|
>
|
||||||
{s.detail && <CountrySheet s={s} />}
|
{s.detail && <CountrySheet s={s} />}
|
||||||
@@ -56,77 +56,82 @@ function CountrySheet({ s }: { s: AtlasGlobeState }): React.ReactElement | null
|
|||||||
const placedTrips = new Set((d.data?.places ?? []).map((p) => p.trip_id));
|
const placedTrips = new Set((d.data?.places ?? []).map((p) => p.trip_id));
|
||||||
const tripsWithoutPlaces = (d.data?.trips ?? []).filter((trip) => !placedTrips.has(trip.id));
|
const tripsWithoutPlaces = (d.data?.trips ?? []).filter((trip) => !placedTrips.has(trip.id));
|
||||||
const openTrip = (id: number) => navigate(`/trips/${id}`);
|
const openTrip = (id: number) => navigate(`/trips/${id}`);
|
||||||
|
const subtitle = row
|
||||||
|
? `${row.tripCount} ${s.t('atlas.trips', { count: row.tripCount })}, ${row.placeCount} ${s.t('atlas.places', { count: row.placeCount })}`
|
||||||
|
: undefined;
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-0 flex-col overflow-y-auto px-5 pb-6 pt-5">
|
<>
|
||||||
<div className="flex items-center gap-3">
|
<FormSheetHeader
|
||||||
<CountryFlag code={d.a2} size={30} />
|
leading={
|
||||||
<div className="min-w-0 flex-1">
|
<span className="grid size-10 flex-none place-items-center rounded-[13px] bg-m-ic">
|
||||||
<div className="truncate text-title font-bold text-m-ink">{s.resolveName(d.a2)}</div>
|
<CountryFlag code={d.a2} size={24} />
|
||||||
{row && (
|
</span>
|
||||||
<div className="text-caption text-m-muted">
|
}
|
||||||
{row.tripCount} {s.t('atlas.trips', { count: row.tripCount })}, {row.placeCount}{' '}
|
title={s.resolveName(d.a2)}
|
||||||
{s.t('atlas.places', { count: row.placeCount })}
|
subtitle={subtitle}
|
||||||
|
onClose={s.closeDialogs}
|
||||||
|
closeLabel={s.t('common.close')}
|
||||||
|
/>
|
||||||
|
<FormSheetBody className="space-y-3">
|
||||||
|
{row && countryStatus(row) !== 'visited' && (
|
||||||
|
<span className="inline-flex items-center gap-1.5 rounded-full bg-m-ic px-2.5 py-1 text-caption font-semibold text-m-muted">
|
||||||
|
<CalendarClock size={14} aria-hidden /> {s.t('atlas.planned')}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{progress && progress.total > 0 && (
|
||||||
|
<FormSheetSection>
|
||||||
|
<div className="flex items-baseline justify-between">
|
||||||
|
<span className="text-caption text-m-muted">{s.t('atlas.regions')}</span>
|
||||||
|
<span className="text-body font-bold tabular-nums text-m-ink">
|
||||||
|
{progress.visited} / {progress.total}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<MProgress
|
||||||
|
value={(progress.visited / Math.max(1, progress.total)) * 100}
|
||||||
|
color="var(--m-act)"
|
||||||
|
height={6}
|
||||||
|
className="mt-2 !bg-m-sheetop"
|
||||||
|
/>
|
||||||
|
</FormSheetSection>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{tripsWithoutPlaces.length > 0 && (
|
||||||
|
<div className="flex gap-2 overflow-x-auto">
|
||||||
|
{tripsWithoutPlaces.map((trip) => (
|
||||||
|
<button
|
||||||
|
key={trip.id}
|
||||||
|
type="button"
|
||||||
|
onClick={() => openTrip(trip.id)}
|
||||||
|
className="inline-flex flex-none items-center gap-1.5 rounded-full bg-[color:var(--m-ic)] px-3 py-2 text-caption font-semibold text-m-ink"
|
||||||
|
>
|
||||||
|
<Briefcase size={13} className="text-m-muted" /> {trip.title}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{d.data ? (
|
||||||
|
<AtlasCountryPlaces variant="mobile" detail={d.data} onOpenTrip={openTrip} />
|
||||||
|
) : (
|
||||||
|
<div className="flex justify-center py-8">
|
||||||
|
<div className="size-6 animate-spin rounded-full border-2 border-[color:var(--m-rowbr)] border-t-[color:var(--m-ink)]" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<MIconBtn variant="neutral" size={34} ariaLabel={s.t('common.close')} onClick={s.closeDialogs}>
|
|
||||||
<X size={17} />
|
|
||||||
</MIconBtn>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{row && countryStatus(row) !== 'visited' && (
|
{d.data?.manually_marked && (
|
||||||
<span className="mt-3 inline-flex items-center gap-1.5 self-start rounded-full bg-[color:var(--m-ic)] px-2.5 py-1 text-caption font-semibold text-m-muted">
|
<button
|
||||||
<CalendarClock size={12} /> {s.t('atlas.planned')}
|
type="button"
|
||||||
</span>
|
onClick={s.askUnmarkDetail}
|
||||||
)}
|
className="min-h-11 w-full rounded-xl bg-m-ic px-3 py-2 text-control font-semibold"
|
||||||
|
style={{ color: 'var(--m-st-danger)' }}
|
||||||
{progress && progress.total > 0 && (
|
>
|
||||||
<div className={`${M_CARD} mt-4 px-4 py-3.5`}>
|
{s.t('atlas.unmark')}
|
||||||
<div className="flex items-baseline justify-between">
|
</button>
|
||||||
<span className="text-caption text-m-muted">{s.t('atlas.regions')}</span>
|
|
||||||
<span className="text-body font-bold tabular-nums text-m-ink">
|
|
||||||
{progress.visited} / {progress.total}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<MProgress value={(progress.visited / Math.max(1, progress.total)) * 100} height={6} className="mt-2" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{tripsWithoutPlaces.length > 0 && (
|
|
||||||
<div className="-mx-5 mt-4 flex gap-2 overflow-x-auto px-5">
|
|
||||||
{tripsWithoutPlaces.map((trip) => (
|
|
||||||
<button
|
|
||||||
key={trip.id}
|
|
||||||
type="button"
|
|
||||||
onClick={() => openTrip(trip.id)}
|
|
||||||
className="inline-flex flex-none items-center gap-1.5 rounded-full bg-[color:var(--m-ic)] px-3 py-2 text-caption font-semibold text-m-ink"
|
|
||||||
>
|
|
||||||
<Briefcase size={13} className="text-m-muted" /> {trip.title}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="mt-4">
|
|
||||||
{d.data ? (
|
|
||||||
<AtlasCountryPlaces variant="mobile" detail={d.data} onOpenTrip={openTrip} />
|
|
||||||
) : (
|
|
||||||
<div className="flex justify-center py-8">
|
|
||||||
<div className="size-6 animate-spin rounded-full border-2 border-[color:var(--m-rowbr)] border-t-[color:var(--m-ink)]" />
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</FormSheetBody>
|
||||||
|
</>
|
||||||
{d.data?.manually_marked && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={s.askUnmarkDetail}
|
|
||||||
className="mt-5 w-full rounded-[16px] bg-[color:var(--m-ic)] py-3 text-body font-semibold"
|
|
||||||
style={{ color: 'var(--m-st-danger)' }}
|
|
||||||
>
|
|
||||||
{s.t('atlas.unmark')}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|||||||
import { buildAtlasData } from '../../../../tests/helpers/atlas';
|
import { buildAtlasData } from '../../../../tests/helpers/atlas';
|
||||||
import { buildGlobeState } from '../../../../tests/helpers/atlasGlobeState';
|
import { buildGlobeState } from '../../../../tests/helpers/atlasGlobeState';
|
||||||
import { act, fireEvent, render, screen } from '../../../../tests/helpers/render';
|
import { act, fireEvent, render, screen } from '../../../../tests/helpers/render';
|
||||||
|
import { setSizeClass } from '../../../../tests/helpers/sizeClass';
|
||||||
import type { GlobeEngine } from '../../../components/AtlasGlobe/GlobeEngine';
|
import type { GlobeEngine } from '../../../components/AtlasGlobe/GlobeEngine';
|
||||||
import type { AtlasGlobeState } from '../../../pages/atlas/useAtlasGlobe';
|
import type { AtlasGlobeState } from '../../../pages/atlas/useAtlasGlobe';
|
||||||
import MAtlasGlobe from './MAtlasGlobe';
|
import MAtlasGlobe from './MAtlasGlobe';
|
||||||
@@ -37,7 +38,7 @@ vi.mock('../../../pages/atlas/useAtlasGlobe', () => ({
|
|||||||
vi.mock('../../../pages/atlas/useGlobeStats', () => ({
|
vi.mock('../../../pages/atlas/useGlobeStats', () => ({
|
||||||
useGlobeStats: (s: unknown) => {
|
useGlobeStats: (s: unknown) => {
|
||||||
fake.statsArg = s;
|
fake.statsArg = s;
|
||||||
return [{ key: 'countries' }];
|
return [{ key: 'countries', value: 1, label: 'Countries' }];
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
vi.mock('../../../components/AtlasGlobe/AtlasGlobe', () => ({
|
vi.mock('../../../components/AtlasGlobe/AtlasGlobe', () => ({
|
||||||
@@ -75,9 +76,6 @@ vi.mock('../../../pages/atlas/AtlasGlobeTimeline', () => ({ default: () => null
|
|||||||
vi.mock('../../../pages/atlas/AtlasBadgeUnlock', () => ({ default: () => null }));
|
vi.mock('../../../pages/atlas/AtlasBadgeUnlock', () => ({ default: () => null }));
|
||||||
vi.mock('./MAtlasCountrySheets', () => ({ default: () => null }));
|
vi.mock('./MAtlasCountrySheets', () => ({ default: () => null }));
|
||||||
vi.mock('./hub/MAtlasHub', () => ({ default: () => null }));
|
vi.mock('./hub/MAtlasHub', () => ({ default: () => null }));
|
||||||
vi.mock('./MAtlasStatsCard', () => ({
|
|
||||||
default: ({ stats }: { stats: unknown[] }) => <p>stats:{stats.length}</p>,
|
|
||||||
}));
|
|
||||||
vi.mock('./MAtlasLayersSheet', () => ({
|
vi.mock('./MAtlasLayersSheet', () => ({
|
||||||
default: ({ open, onClose }: { open: boolean; onClose: () => void }) =>
|
default: ({ open, onClose }: { open: boolean; onClose: () => void }) =>
|
||||||
open ? (
|
open ? (
|
||||||
@@ -112,7 +110,7 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MAtlasGlobe', () => {
|
describe('MAtlasGlobe', () => {
|
||||||
it('FE-ATLAS2-MOBILE-200: the globe gets the state, dark and room for the cards at the foot', () => {
|
it('FE-ATLAS2-MOBILE-200: the phone globe reserves room for the Atlas progress card', () => {
|
||||||
const s = buildGlobeState();
|
const s = buildGlobeState();
|
||||||
show(s);
|
show(s);
|
||||||
expect(screen.getByTestId('globe')).toBeInTheDocument();
|
expect(screen.getByTestId('globe')).toBeInTheDocument();
|
||||||
@@ -120,10 +118,21 @@ describe('MAtlasGlobe', () => {
|
|||||||
expect(globe.fetchJson).toBe(s.fetchJson);
|
expect(globe.fetchJson).toBe(s.fetchJson);
|
||||||
expect(globe.paintKey).toBe('k');
|
expect(globe.paintKey).toBe('k');
|
||||||
expect(globe.dark).toBe(true);
|
expect(globe.dark).toBe(true);
|
||||||
expect(globe.insetBottom).toBe(170);
|
expect(globe.insetBottom).toBe(144);
|
||||||
expect(Object.keys(fake.hookArgs[0] ?? {}).sort()).toEqual(['globeRef', 'skyRef']);
|
expect(Object.keys(fake.hookArgs[0] ?? {}).sort()).toEqual(['globeRef', 'skyRef']);
|
||||||
expect(fake.statsArg).toBe(s);
|
expect(fake.statsArg).toBe(s);
|
||||||
expect(screen.getByText('stats:1')).toBeInTheDocument();
|
expect(screen.getByText('1 / 195')).toBeVisible();
|
||||||
|
expect(screen.getByRole('button', { name: 'atlas.globe.hub' })).toHaveAccessibleDescription(
|
||||||
|
/atlas.visitedCountries/
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps the statistics strip at wide widths', () => {
|
||||||
|
setSizeClass('wide');
|
||||||
|
show(buildGlobeState());
|
||||||
|
expect(fake.globe?.insetBottom).toBe(170);
|
||||||
|
expect(screen.getByRole('button', { name: '1 Countries' })).toBeVisible();
|
||||||
|
expect(screen.queryByText('1 / 195')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('FE-ATLAS2-MOBILE-201: every frame lays out the sky and the pins on the engine', () => {
|
it('FE-ATLAS2-MOBILE-201: every frame lays out the sky and the pins on the engine', () => {
|
||||||
@@ -144,16 +153,16 @@ describe('MAtlasGlobe', () => {
|
|||||||
expect(s.setError).toHaveBeenLastCalledWith('lost context');
|
expect(s.setError).toHaveBeenLastCalledWith('lost context');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('FE-ATLAS2-MOBILE-203: the hub button opens the hub on its last tab and lights up while it is open', () => {
|
it('FE-ATLAS2-MOBILE-203: the Atlas progress opens the hub on its last tab', () => {
|
||||||
const s = buildGlobeState({ passportTab: 'badges' });
|
const s = buildGlobeState({ passportTab: 'badges' });
|
||||||
const { unmount } = show(s);
|
const { unmount } = show(s);
|
||||||
const hub = screen.getByRole('button', { name: 'atlas.globe.hub' });
|
const hub = screen.getByRole('button', { name: 'atlas.globe.hub' });
|
||||||
expect(hub.className).toContain('text-content-secondary');
|
expect(hub).toHaveAttribute('aria-expanded', 'false');
|
||||||
fireEvent.click(hub);
|
fireEvent.click(hub);
|
||||||
expect(s.openPassport).toHaveBeenCalledWith('badges');
|
expect(s.openPassport).toHaveBeenCalledWith('badges');
|
||||||
unmount();
|
unmount();
|
||||||
show(buildGlobeState({ passportOpen: true }));
|
show(buildGlobeState({ passportOpen: true }));
|
||||||
expect(screen.getByRole('button', { name: 'atlas.globe.hub' }).className).toContain('bg-accent');
|
expect(screen.getByRole('button', { name: 'atlas.globe.hub' })).toHaveAttribute('aria-expanded', 'true');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('FE-ATLAS2-MOBILE-204: the layers button opens the layers sheet, which closes again', () => {
|
it('FE-ATLAS2-MOBILE-204: the layers button opens the layers sheet, which closes again', () => {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import GlobePins, { type GlobePinsHandle } from '../../../components/AtlasGlobe/
|
|||||||
import GlobeSky, { type GlobeSkyHandle } from '../../../components/AtlasGlobe/GlobeSky';
|
import GlobeSky, { type GlobeSkyHandle } from '../../../components/AtlasGlobe/GlobeSky';
|
||||||
import '../../../components/AtlasGlobe/atlasGlobe.css';
|
import '../../../components/AtlasGlobe/atlasGlobe.css';
|
||||||
import { segmentStyle } from '../../../components/Map/mapControlShadow';
|
import { segmentStyle } from '../../../components/Map/mapControlShadow';
|
||||||
|
import { useIsWide } from '../../../hooks/sizeClass';
|
||||||
import AtlasBadgeUnlock from '../../../pages/atlas/AtlasBadgeUnlock';
|
import AtlasBadgeUnlock from '../../../pages/atlas/AtlasBadgeUnlock';
|
||||||
import AtlasGlobeSearch from '../../../pages/atlas/AtlasGlobeSearch';
|
import AtlasGlobeSearch from '../../../pages/atlas/AtlasGlobeSearch';
|
||||||
import AtlasGlobeStatus from '../../../pages/atlas/AtlasGlobeStatus';
|
import AtlasGlobeStatus from '../../../pages/atlas/AtlasGlobeStatus';
|
||||||
@@ -18,19 +19,20 @@ import { useAtlasGlobe } from '../../../pages/atlas/useAtlasGlobe';
|
|||||||
import { useGlobeStats } from '../../../pages/atlas/useGlobeStats';
|
import { useGlobeStats } from '../../../pages/atlas/useGlobeStats';
|
||||||
import MAtlasCountrySheets from './MAtlasCountrySheets';
|
import MAtlasCountrySheets from './MAtlasCountrySheets';
|
||||||
import MAtlasLayersSheet from './MAtlasLayersSheet';
|
import MAtlasLayersSheet from './MAtlasLayersSheet';
|
||||||
import MAtlasStatsCard from './MAtlasStatsCard';
|
import MAtlasStatsCard, { MAtlasProgressCard } from './MAtlasStatsCard';
|
||||||
import MAtlasHub from './hub/MAtlasHub';
|
import MAtlasHub from './hub/MAtlasHub';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The globe Atlas on the phone: the globe fills the screen under the shell,
|
* The globe Atlas on the phone: the globe fills the screen under the shell,
|
||||||
* search on top, the numbers as a row of cards above the bottom nav, and the
|
* search on top and the Atlas progress above the bottom nav.
|
||||||
* same dialogs as the desktop. State and data come from useAtlasGlobe.
|
* State and data come from useAtlasGlobe.
|
||||||
*/
|
*/
|
||||||
export default function MAtlasGlobe(): React.ReactElement {
|
export default function MAtlasGlobe(): React.ReactElement {
|
||||||
const globeRef = React.useRef<AtlasGlobeHandle>(null);
|
const globeRef = React.useRef<AtlasGlobeHandle>(null);
|
||||||
const skyRef = React.useRef<GlobeSkyHandle>(null);
|
const skyRef = React.useRef<GlobeSkyHandle>(null);
|
||||||
const s = useAtlasGlobe({ globeRef, skyRef });
|
const s = useAtlasGlobe({ globeRef, skyRef });
|
||||||
const stats = useGlobeStats(s);
|
const stats = useGlobeStats(s);
|
||||||
|
const wide = useIsWide();
|
||||||
const [layersOpen, setLayersOpen] = React.useState(false);
|
const [layersOpen, setLayersOpen] = React.useState(false);
|
||||||
const pinsRef = React.useRef<GlobePinsHandle>(null);
|
const pinsRef = React.useRef<GlobePinsHandle>(null);
|
||||||
// The dock's search button hands over with ?search=1, as on every screen: take
|
// The dock's search button hands over with ?search=1, as on every screen: take
|
||||||
@@ -66,7 +68,7 @@ export default function MAtlasGlobe(): React.ReactElement {
|
|||||||
onReady={s.onReady}
|
onReady={s.onReady}
|
||||||
onFrame={onFrame}
|
onFrame={onFrame}
|
||||||
onError={(err) => s.setError(err instanceof Error ? err.message : String(err))}
|
onError={(err) => s.setError(err instanceof Error ? err.message : String(err))}
|
||||||
insetBottom={170}
|
insetBottom={wide ? 170 : 144}
|
||||||
/>
|
/>
|
||||||
<div className="pointer-events-none absolute inset-0">
|
<div className="pointer-events-none absolute inset-0">
|
||||||
<GlobeSky ref={skyRef} dark />
|
<GlobeSky ref={skyRef} dark />
|
||||||
@@ -79,43 +81,42 @@ export default function MAtlasGlobe(): React.ReactElement {
|
|||||||
<AtlasGlobeSearch
|
<AtlasGlobeSearch
|
||||||
s={s}
|
s={s}
|
||||||
focusSignal={focusSearch}
|
focusSignal={focusSearch}
|
||||||
className={`end-[102px] start-3 top-[var(--m-safe-top,12px)]`}
|
className={`${wide ? 'end-[102px]' : 'end-[64px]'} start-3 top-[var(--m-safe-top,12px)]`}
|
||||||
/>
|
/>
|
||||||
<div
|
<div className="ag-liquid pointer-events-auto absolute end-3 top-[var(--m-safe-top,12px)] z-30 flex h-11 items-center gap-0.5 rounded-full">
|
||||||
className="ag-liquid pointer-events-auto absolute end-3 top-[var(--m-safe-top,12px)] flex h-11 items-center rounded-full p-1"
|
{wide && (
|
||||||
style={{ gap: 2 }}
|
<button
|
||||||
>
|
type="button"
|
||||||
{/* The hub on the phone: one button for statistics, badges, wishes, tours
|
className={s.passportOpen ? 'ms-1 bg-accent text-accent-text' : 'ms-1 text-content-secondary'}
|
||||||
and travellers; a new badge flies into it. */}
|
style={segmentStyle(s.passportOpen)}
|
||||||
|
onClick={() => s.openPassport(s.passportTab)}
|
||||||
|
aria-label={s.t('atlas.globe.hub')}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
data-atlas-badges-btn
|
||||||
|
>
|
||||||
|
<Globe2 size={16} aria-hidden />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={s.passportOpen ? 'bg-accent text-accent-text' : 'text-content-secondary'}
|
className={`grid size-11 place-items-center rounded-full ${layersOpen ? 'bg-accent text-accent-text' : 'text-content-secondary'}`}
|
||||||
style={segmentStyle(s.passportOpen)}
|
|
||||||
onClick={() => s.openPassport(s.passportTab)}
|
|
||||||
aria-label={s.t('atlas.globe.hub')}
|
|
||||||
data-atlas-badges-btn
|
|
||||||
>
|
|
||||||
<Globe2 size={16} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={layersOpen ? 'bg-accent text-accent-text' : 'text-content-secondary'}
|
|
||||||
style={segmentStyle(layersOpen)}
|
|
||||||
onClick={() => setLayersOpen(true)}
|
onClick={() => setLayersOpen(true)}
|
||||||
aria-label={s.t('atlas.globe.layers')}
|
aria-label={s.t('atlas.globe.layers')}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-expanded={layersOpen}
|
||||||
>
|
>
|
||||||
<Layers size={16} />
|
<Layers size={18} aria-hidden />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MAtlasStatsCard stats={stats} />
|
{wide ? <MAtlasStatsCard stats={stats} /> : <MAtlasProgressCard s={s} />}
|
||||||
|
|
||||||
<AtlasGlobeTimeline s={s} className="end-3 start-3 top-[calc(var(--m-safe-top,12px)+56px)]" />
|
<AtlasGlobeTimeline s={s} className="end-3 start-3 top-[calc(var(--m-safe-top,12px)+56px)]" />
|
||||||
<AtlasBadgeUnlock s={s} />
|
<AtlasBadgeUnlock s={s} />
|
||||||
<MAtlasLayersSheet s={s} open={layersOpen} onClose={() => setLayersOpen(false)} />
|
<MAtlasLayersSheet s={s} open={layersOpen} onClose={() => setLayersOpen(false)} />
|
||||||
<MAtlasCountrySheets s={s} />
|
<MAtlasCountrySheets s={s} />
|
||||||
<MAtlasHub s={s} />
|
<MAtlasHub s={s} />
|
||||||
<MCompareBar s={s} />
|
<MCompareBar s={s} wide={wide} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -124,7 +125,7 @@ export default function MAtlasGlobe(): React.ReactElement {
|
|||||||
* The overlay with another traveller on the phone: who, the three counts with
|
* The overlay with another traveller on the phone: who, the three counts with
|
||||||
* their colours, the gaps switch and the way out, as one card above the numbers.
|
* their colours, the gaps switch and the way out, as one card above the numbers.
|
||||||
*/
|
*/
|
||||||
function MCompareBar({ s }: { s: AtlasGlobeState }): React.ReactElement | null {
|
function MCompareBar({ s, wide }: { s: AtlasGlobeState; wide: boolean }): React.ReactElement | null {
|
||||||
const p = s.compareWith;
|
const p = s.compareWith;
|
||||||
if (!p) return null;
|
if (!p) return null;
|
||||||
const mine = (s.data?.countries ?? []).filter((c) => countryStatus(c) === 'visited').map((c) => c.code);
|
const mine = (s.data?.countries ?? []).filter((c) => countryStatus(c) === 'visited').map((c) => c.code);
|
||||||
@@ -135,7 +136,11 @@ function MCompareBar({ s }: { s: AtlasGlobeState }): React.ReactElement | null {
|
|||||||
[COMPARE_COLORS.mine, c.mineOnly, s.t('atlas.globe.onlyYou')],
|
[COMPARE_COLORS.mine, c.mineOnly, s.t('atlas.globe.onlyYou')],
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<div className="ag-liquid pointer-events-auto absolute inset-x-3 bottom-[calc(var(--bottom-nav-h,84px)+92px)] z-30 flex flex-col gap-2 rounded-[20px] px-3.5 py-3">
|
<div
|
||||||
|
className={`ag-liquid pointer-events-auto absolute inset-x-3 z-30 flex flex-col gap-2 rounded-[20px] px-3.5 py-3 ${
|
||||||
|
wide ? 'bottom-[calc(var(--bottom-nav-h,84px)+92px)]' : 'bottom-[calc(var(--bottom-nav-h,84px)+76px)]'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="min-w-0 flex-1 truncate text-body font-semibold">
|
<span className="min-w-0 flex-1 truncate text-body font-semibold">
|
||||||
{s.t('atlas.globe.compareWith', { name: p.username })}
|
{s.t('atlas.globe.compareWith', { name: p.username })}
|
||||||
|
|||||||
@@ -73,4 +73,14 @@ describe('MAtlasLayersSheet', () => {
|
|||||||
fireEvent.click(screen.getByRole('button', { name: 'common.close' }));
|
fireEvent.click(screen.getByRole('button', { name: 'common.close' }));
|
||||||
expect(onClose).toHaveBeenCalledOnce();
|
expect(onClose).toHaveBeenCalledOnce();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shows the years on the globe when there is a visit history', () => {
|
||||||
|
const setTimelineOpen = vi.fn();
|
||||||
|
const onClose = vi.fn();
|
||||||
|
const s = buildGlobeState({ totals: { firstYear: 2020 }, timelineOpen: false, setTimelineOpen });
|
||||||
|
render(<MAtlasLayersSheet s={s} open onClose={onClose} />);
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'atlas.years' }));
|
||||||
|
expect(setTimelineOpen).toHaveBeenCalledWith(true);
|
||||||
|
expect(onClose).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user