merge: update Tours branch with current Places filters

This commit is contained in:
elmocito
2026-10-05 01:50:47 +02:00
63 changed files with 1008 additions and 183 deletions
+8 -1
View File
@@ -10,16 +10,23 @@ interface MChipProps {
* back what it can: the chips that start a search are the ones worth the height.
*/
size?: 'sm' | 'tap'
/**
* The chip is one choice of a picker: announce `active` as `aria-pressed`, so a
* screen reader hears which one is on, not just its colour. Off by default, for
* chips that only run an action.
*/
pressable?: boolean
className?: string
children: ReactNode
}
/** Small pill chip: --m-act when active, neutral --m-ic surface otherwise. */
export default function MChip({ active = false, onClick, size = 'sm', className = '', children }: MChipProps) {
export default function MChip({ active = false, onClick, size = 'sm', pressable = false, className = '', children }: MChipProps) {
return (
<button
type="button"
onClick={onClick}
aria-pressed={pressable ? active : undefined}
className={`inline-flex flex-none items-center gap-[6px] rounded-full font-semibold ${
size === 'tap' ? 'px-[13px] py-[10px] text-[0.8125rem]' : 'px-3 py-[7px] text-[0.75rem]'
} ${
@@ -54,7 +54,7 @@ export type MTripCollabTab = 'chat' | 'notes' | 'links' | 'polls'
* { dayId, note? }), 'accommodation' (payload { dayId?, accId?, from? }),
* 'transport' (payload { reservationId }), 'bract'
* (payload { placeId, dayPicker? }), 'import', 'export', 'members',
* 'tripedit', 'bags', 'task'. The place inspector keys off the planner's
* 'tripedit', 'bags', 'task', 'placesFilter' (the map's places filter). The place inspector keys off the planner's
* place selection instead of a sheet id, and planner-backed editors (place
* form, transport, booking, expense) keep using the planner's own modal flags.
*/
@@ -4,6 +4,7 @@ import { MapCompassPill, type CompassMap } from '../../../../components/Map/MapC
import { MAP_LAYER_SWITCHER_INSET, MAP_ROUND_CONTROL_SIZE } from '../../../../components/Map/MapLayerSwitcher'
import { TripRouteOverviewPill, TripRouteOverviewPanel } from '../../../../components/Map/TripRouteOverview'
import { DawarichTrailPill } from '../../../../components/Map/DawarichTrailPill'
import { MPlacesFilterPill } from './MPlacesFilterPill'
import PoiCategoryPill from '../../../../components/Map/PoiCategoryPill'
import { usePoiExplore } from '../../../../components/Map/usePoiExplore'
import { useMergedMapPois } from '../../../../components/Map/useMergedMapPois'
@@ -452,8 +453,11 @@ export default function MMapArea({ planner, shell }: MMapAreaProps) {
clear of the round-controls band below it and of the base-layer switcher and
the compass, which both sit bottom left. The offset is Tailwind rather than
inline because the compass band is identified by being the one element with
an inline --bottom-nav-h, and a second would make that ambiguous. */}
{mapActive && !onStage && (!planner.roadtripActive || planner.dawarichEnabled) && (
an inline --bottom-nav-h, and a second would make that ambiguous. The places
filter closes the stack, under the toggles, so the overview card stays
right above its own toggle: it decides which pins the plan map shows, so it is
there whatever else is; the stage draws its own pins and has no use for it. */}
{mapActive && !onStage && (
<div className="pointer-events-none absolute left-3 right-3 z-[25] flex flex-col items-end gap-2 bottom-[calc(var(--bottom-nav-h,84px)+58px)]">
{!planner.roadtripActive && planner.overviewActive && (
<TripRouteOverviewPanel
@@ -478,6 +482,7 @@ export default function MMapArea({ planner, shell }: MMapAreaProps) {
onToggle={planner.toggleDawarichTrail}
/>
)}
<MPlacesFilterPill onOpen={() => shell.openSheet('placesFilter')} />
</div>
)}
</div>
@@ -0,0 +1,31 @@
import { SlidersHorizontal } from 'lucide-react'
import { MapTogglePill } from '../../../../components/Map/MapTogglePill'
import { useTripStore } from '../../../../store/tripStore'
import { countActivePlacesFilters } from '../../../../utils/placesFilter'
import { useTranslation } from '../../../../i18n'
/**
* The phone map's way into the places filter: a round control in the right-hand
* stack, lit and badged with how many filters are narrowing the markers. The sheet
* it opens is the shell's 'placesFilter' sheet, so the button announces a dialog
* rather than a pressed state.
*/
export function MPlacesFilterPill({ onOpen }: { onOpen: () => void }) {
const { t } = useTranslation()
const filter = useTripStore(s => s.placesFilter)
const categoryFilters = useTripStore(s => s.placesCategoryFilter)
const ratingFilter = useTripStore(s => s.placesRatingFilter)
const count = countActivePlacesFilters({ filter, categoryFilters, ratingFilter })
const label = count > 0 ? `${t('places.filters')} (${count})` : t('places.filters')
return (
<MapTogglePill
active={count > 0}
onToggle={onOpen}
label={label}
badge={count}
testId="places-filter-pill"
opensDialog
icon={<SlidersHorizontal size={17} strokeWidth={2} />}
/>
)
}
@@ -1,6 +1,6 @@
import { ReactNode, useEffect, useMemo, useState } from 'react'
import {
Bookmark, Check, CheckCheck, CheckCircle2, Download, ListChecks, Loader2, MapPin, Plus,
Bookmark, CheckCheck, CheckCircle2, Download, ListChecks, Loader2, Plus,
SlidersHorizontal, Tag, Trash2, X,
} from 'lucide-react'
import MDancingTrek from '../../../components/MDancingTrek'
@@ -25,6 +25,8 @@ import MPlacesToursModeSwitch from './MPlacesToursModeSwitch'
import MToursSelectionList from './MToursSelectionList'
import { filterPool, firstPlannedDayNumbers, plannedPlaceIds } from './placesBrowserModel'
import { useTourPlaceIds } from '../../../../hooks/useTourPlaceIds'
import { MCategoryFilterList, MRatingFloorChips, SquareCheck } from './MPlacesFilterControls'
import { countActivePlacesFilters } from '../../../../utils/placesFilter'
/**
* Fullscreen places pool (mode === 'browse'): All/Unplanned/Tracks filter
@@ -55,7 +57,7 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
const filter = useTripStore(s => s.placesFilter)
const setFilter = useTripStore(s => s.setPlacesFilter)
const categoryFilters = useTripStore(s => s.placesCategoryFilter)
const setCategoryFilters = useTripStore(s => s.setPlacesCategoryFilter)
const ratingFilter = useTripStore(s => s.placesRatingFilter)
const [search, setSearch] = useState('')
const [catOpen, setCatOpen] = useState(false)
@@ -73,9 +75,6 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
}, [shell.browseFromEdit, setFilter])
const hasTracks = useMemo(() => !toursEnabled && places.some(p => p.route_geometry), [places, toursEnabled])
useEffect(() => {
if (filter === 'tracks' && !hasTracks) setFilter('all')
}, [filter, hasTracks, setFilter])
// A hotel is linked through its stay and a venue through its booking; neither is
// ever dragged onto a day, and the pool used to call both unplanned (#2072).
@@ -84,10 +83,13 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
[assignments, planner.tripAccommodations, planner.reservations],
)
const dayNumberByPlace = useMemo(() => firstPlannedDayNumbers(assignments, days), [assignments, days])
const poolPlaces = useMemo(
() => toursEnabled ? places.filter(place => !tourPlaceIds.has(place.id)) : places,
[places, toursEnabled, tourPlaceIds],
)
const filtered = useMemo(() => {
const pool = toursEnabled ? places.filter(p => !tourPlaceIds.has(p.id)) : places
return filterPool(pool, { filter, categoryFilters, search, plannedIds })
}, [places, filter, categoryFilters, search, plannedIds, toursEnabled, tourPlaceIds])
return filterPool(poolPlaces, { filter, categoryFilters, ratingFilter, search, plannedIds })
}, [poolPlaces, filter, categoryFilters, ratingFilter, search, plannedIds])
// A bulk delete (or a remote edit) can remove selected places — drop the
// stale ids so the toolbar count stays honest.
@@ -138,13 +140,6 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
else setSelectedIds(new Set(selectablePlaces.map(p => p.id)))
}
const toggleCategory = (catId: string) => {
const next = new Set(categoryFilters)
if (next.has(catId)) next.delete(catId)
else next.add(catId)
setCategoryFilters(next)
}
const openAddPlace = () => {
planner.setEditingPlace(null)
planner.setEditingAssignmentId(null)
@@ -165,12 +160,11 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
}
const selectedTours = [...selectedIds].filter(planner.isTourPlace)
const hasUncategorized = places.some(p => p.category_id == null)
const panelFilterCount = countActivePlacesFilters({ filter: 'all', categoryFilters, ratingFilter })
return (
<div className="flex h-full flex-col">
<div className="min-h-0 flex-1 overflow-y-auto px-4 pb-[calc(var(--bottom-nav-h,84px)+22px)] pt-[calc(var(--m-safe-top,12px)+58px)]">
<div className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 pb-[calc(var(--bottom-nav-h,84px)+22px)] pt-[calc(var(--m-safe-top,12px)+58px)]">
{toursEnabled && (
<MPlacesToursModeSwitch active={toursMode} onChange={setToursMode} />
)}
@@ -235,13 +229,13 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
type="button"
onClick={() => setCatOpen(v => !v)}
aria-expanded={catOpen}
aria-label={t('places.allCategories')}
aria-label={t('places.filters')}
className="relative flex w-[42px] flex-none items-center justify-center rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] text-m-muted"
>
<SlidersHorizontal size={15} strokeWidth={2} />
{categoryFilters.size > 0 && (
{panelFilterCount > 0 && (
<span className="absolute -right-[3px] -top-[3px] box-border flex h-4 min-w-[16px] items-center justify-center rounded-full bg-m-act px-1 font-geist text-[0.5625rem] font-bold text-m-actfg">
{categoryFilters.size}
{panelFilterCount}
</span>
)}
</button>
@@ -324,31 +318,13 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
</div>
)}
{/* ── Category filter panel ── */}
{/* ── Rating + category filter panel ── */}
{catOpen && (
<div className="mt-[6px] overflow-hidden rounded-2xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-glass)]">
{categories.map(c => {
const CatIcon = getCategoryIcon(c.icon)
return (
<CategoryFilterRow
key={c.id}
checked={categoryFilters.has(String(c.id))}
onToggle={() => toggleCategory(String(c.id))}
label={c.name}
>
<CatIcon size={14} strokeWidth={2} className="flex-none" style={{ color: c.color || 'var(--m-muted)' }} />
</CategoryFilterRow>
)
})}
{hasUncategorized && (
<CategoryFilterRow
checked={categoryFilters.has('uncategorized')}
onToggle={() => toggleCategory('uncategorized')}
label={t('places.noCategory')}
>
<MapPin size={14} strokeWidth={2} className="flex-none text-m-faint" />
</CategoryFilterRow>
)}
<div className="border-b border-[color:var(--m-rowbr)] px-[13px] py-[10px]">
<MRatingFloorChips onPick={() => setSelectedIds(new Set())} />
</div>
<MCategoryFilterList categories={categories} places={poolPlaces} />
</div>
)}
@@ -363,7 +339,7 @@ export default function MPlacesBrowser({ planner, shell }: MPlacesBrowserProps)
{/* ── Place list ── */}
{filtered.length === 0 ? (
filter === 'unplanned' && !search && categoryFilters.size === 0 ? (
filter === 'unplanned' && !search && categoryFilters.size === 0 && ratingFilter === 'all' ? (
<div className="flex min-h-[60vh] flex-col items-center justify-center px-8 py-10 text-center">
<MDancingTrek scene="idle" mood="happy" className="mb-2" />
<p className="font-geist text-[0.8125rem] font-medium text-m-muted">{t('places.allPlanned')}</p>
@@ -510,37 +486,3 @@ function BulkBtn({ label, onClick, disabled = false, children }: {
</button>
)
}
/** 17px (panel) / 19px (row) square checkbox in the demo's act-fill style. */
function SquareCheck({ checked, big = false }: { checked: boolean; big?: boolean }) {
return (
<span
className={`flex flex-none items-center justify-center border-[1.5px] ${
big ? 'h-[19px] w-[19px] rounded-[6px]' : 'h-[17px] w-[17px] rounded-[5px]'
} ${checked ? 'border-[color:var(--m-act)] bg-m-act text-m-actfg' : 'border-[color:var(--m-trackoff)] text-transparent'}`}
>
<Check size={big ? 12 : 11} strokeWidth={3} />
</span>
)
}
function CategoryFilterRow({ checked, onToggle, label, children }: {
checked: boolean
onToggle: () => void
label: string
children: ReactNode
}) {
return (
<button
type="button"
onClick={onToggle}
role="checkbox"
aria-checked={checked}
className="flex w-full items-center gap-[10px] border-b border-[color:var(--m-rowbr)] px-[13px] py-[10px] text-left last:border-b-0"
>
<SquareCheck checked={checked} />
{children}
<span className="min-w-0 flex-1 truncate text-[0.78125rem] font-medium text-m-ink">{label}</span>
</button>
)
}
@@ -0,0 +1,112 @@
import { ReactNode } from 'react'
import { Check, MapPin, Star } from 'lucide-react'
import MChip from '../../../components/MChip'
import { useTripStore } from '../../../../store/tripStore'
import { getCategoryIcon } from '../../../../components/shared/categoryIcons'
import { RATING_FLOORS, UNCATEGORIZED } from '../../../../utils/placesFilter'
import { useTranslation } from '../../../../i18n'
import type { Category, Place } from '../../../../types'
/**
* The phone's places filter controls, shared by the places browser's filter panel
* and the map's filter sheet. Both read and write the trip store, so whichever one
* the user touches, the list and the map markers follow (#1541).
*/
/** 17px (panel) / 19px (row) square checkbox in the demo's act-fill style. */
export function SquareCheck({ checked, big = false }: { checked: boolean; big?: boolean }) {
return (
<span
className={`flex flex-none items-center justify-center border-[1.5px] ${
big ? 'h-[19px] w-[19px] rounded-[6px]' : 'h-[17px] w-[17px] rounded-[5px]'
} ${checked ? 'border-[color:var(--m-act)] bg-m-act text-m-actfg' : 'border-[color:var(--m-trackoff)] text-transparent'}`}
>
<Check size={big ? 12 : 11} strokeWidth={3} />
</span>
)
}
function CategoryFilterRow({ checked, onToggle, label, children }: {
checked: boolean
onToggle: () => void
label: string
children: ReactNode
}) {
return (
<button
type="button"
onClick={onToggle}
role="checkbox"
aria-checked={checked}
className="flex min-h-[44px] w-full items-center gap-[10px] border-b border-[color:var(--m-rowbr)] px-[13px] py-[10px] text-left last:border-b-0"
>
<SquareCheck checked={checked} />
{children}
<span className="min-w-0 flex-1 truncate text-[0.78125rem] font-medium text-m-ink">{label}</span>
</button>
)
}
/** The trip's categories as a multi-select, plus "no category" while a place has none. */
export function MCategoryFilterList({ categories, places }: { categories: Category[]; places: Place[] }) {
const { t } = useTranslation()
const categoryFilters = useTripStore(s => s.placesCategoryFilter)
const setCategoryFilters = useTripStore(s => s.setPlacesCategoryFilter)
const toggle = (catId: string) => {
const next = new Set(categoryFilters)
if (next.has(catId)) next.delete(catId)
else next.add(catId)
setCategoryFilters(next)
}
return (
<>
{categories.map(c => {
const CatIcon = getCategoryIcon(c.icon)
return (
<CategoryFilterRow
key={c.id}
checked={categoryFilters.has(String(c.id))}
onToggle={() => toggle(String(c.id))}
label={c.name}
>
<CatIcon size={14} strokeWidth={2} className="flex-none" style={{ color: c.color || 'var(--m-muted)' }} />
</CategoryFilterRow>
)
})}
{places.some(p => p.category_id == null) && (
<CategoryFilterRow
checked={categoryFilters.has(UNCATEGORIZED)}
onToggle={() => toggle(UNCATEGORIZED)}
label={t('places.noCategory')}
>
<MapPin size={14} strokeWidth={2} className="flex-none text-m-faint" />
</CategoryFilterRow>
)}
</>
)
}
/**
* A minimum of stars, the same floors as the desktop list and the collections bar
* (#1435). `onPick` runs after a floor is chosen: the places browser drops its
* selection then, as it does for a new pool.
*/
export function MRatingFloorChips({ onPick }: { onPick?: () => void } = {}) {
const { t } = useTranslation()
const ratingFilter = useTripStore(s => s.placesRatingFilter)
const setRatingFilter = useTripStore(s => s.setPlacesRatingFilter)
return (
<div role="group" aria-label={t('places.filterByRating')} className="flex flex-wrap gap-[6px]">
{RATING_FLOORS.map(floor => (
<MChip key={String(floor)} size="tap" pressable active={ratingFilter === floor} onClick={() => { setRatingFilter(floor); onPick?.() }}>
{floor === 'all' ? t('common.all') : (
<>
<Star size={12} strokeWidth={2.2} fill="currentColor" className="flex-none" />
{`${floor}+`}
</>
)}
</MChip>
))}
</div>
)
}
@@ -0,0 +1,100 @@
import { RotateCcw, X } from 'lucide-react'
import MSheet from '../../../components/MSheet'
import MIconBtn from '../../../components/MIconBtn'
import MChip from '../../../components/MChip'
import { useTripStore } from '../../../../store/tripStore'
import { countActivePlacesFilters } from '../../../../utils/placesFilter'
import { useTranslation } from '../../../../i18n'
import type { Category, Place } from '../../../../types'
import { MCategoryFilterList, MRatingFloorChips } from './MPlacesFilterControls'
interface MPlacesFilterSheetProps {
open: boolean
onClose: () => void
places: Place[]
categories: Category[]
toursEnabled: boolean
}
/** Uppercase eyebrow over each group of the sheet. */
function SectionTitle({ children }: { children: string }) {
return (
<div className="mb-2 font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint">{children}</div>
)
}
/**
* The places filter, opened from the phone map: which pool to show, a minimum
* rating and the trip's categories, with one button that lifts them all. Every
* choice lands in the trip store at once, so the markers behind the sheet and the
* places list change with it (#1541). Routed as shell sheet 'placesFilter'.
*/
export default function MPlacesFilterSheet({ open, onClose, places, categories, toursEnabled }: MPlacesFilterSheetProps) {
const { t } = useTranslation()
const filter = useTripStore(s => s.placesFilter)
const categoryFilters = useTripStore(s => s.placesCategoryFilter)
const ratingFilter = useTripStore(s => s.placesRatingFilter)
const setFilter = useTripStore(s => s.setPlacesFilter)
const resetPlacesFilters = useTripStore(s => s.resetPlacesFilters)
const activeCount = countActivePlacesFilters({ filter, categoryFilters, ratingFilter })
const pools = [
{ id: 'all', label: t('places.all') },
{ id: 'unplanned', label: t('places.unplanned') },
{ id: 'planned', label: t('places.planned') },
]
if (!toursEnabled && places.some(p => p.route_geometry)) pools.push({ id: 'tracks', label: t('places.filterTracks') })
const hasCategoryChoice = categories.length > 0 || places.some(p => p.category_id == null)
return (
// Opaque: the sheet opens over the map, and the default bar glass let the map's
// place names show through the chips and category rows (seen at 390px wide).
<MSheet open={open} onClose={onClose} variant="bottom" material="opaque" ariaLabel={t('places.filters')}>
<div className="flex flex-none items-center border-b border-[color:var(--m-rowbr)] px-[18px] pb-[11px] pt-4">
<div className="min-w-0 flex-1 text-[1.03125rem] font-bold text-m-ink">{t('places.filters')}</div>
<MIconBtn variant="neutral" size={34} onClick={onClose} ariaLabel={t('common.close')}>
<X size={15} strokeWidth={2.2} />
</MIconBtn>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-[18px] pb-3 pt-[14px]">
<section>
<SectionTitle>{t('places.filterShow')}</SectionTitle>
<div role="group" aria-label={t('places.filterShow')} className="flex flex-wrap gap-[6px]">
{pools.map(pool => (
<MChip key={pool.id} size="tap" pressable active={filter === pool.id} onClick={() => setFilter(pool.id)}>
{pool.label}
</MChip>
))}
</div>
</section>
<section className="mt-[18px]">
<SectionTitle>{t('places.filterByRating')}</SectionTitle>
<MRatingFloorChips />
</section>
{hasCategoryChoice && (
<section className="mt-[18px]">
<SectionTitle>{t('categories.title')}</SectionTitle>
<div className="overflow-hidden rounded-2xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]">
<MCategoryFilterList categories={categories} places={places} />
</div>
</section>
)}
</div>
<div className="flex flex-none border-t border-[color:var(--m-rowbr)] px-[18px] py-3">
<button
type="button"
onClick={resetPlacesFilters}
disabled={activeCount === 0}
className="flex min-h-[44px] flex-1 items-center justify-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] text-[0.8125rem] font-semibold text-m-ink disabled:opacity-40"
>
<RotateCcw size={14} strokeWidth={2.2} />
{t('common.reset')}
</button>
</div>
</MSheet>
)
}
@@ -1,8 +1,9 @@
import { describe, it, expect } from 'vitest'
import {
filterPool, firstPlannedDayNumbers, matchesCategoryFilter, matchesSearch,
filterPool, firstPlannedDayNumbers, matchesSearch,
plannedPlaceIds, poolCounts,
} from './placesBrowserModel'
import { matchesCategoryFilter } from '../../../../utils/placesFilter'
import type { AssignmentsMap, Day, Place } from '../../../../types'
const mkPlace = (id: number, over: Partial<Place> = {}): Place =>
@@ -144,6 +145,18 @@ describe('placesBrowserModel — tracks pool', () => {
expect(out.map(p => p.id)).toEqual([1])
})
it('FE-MOB-PMODEL-015: the rating floor from the store narrows the pool like it narrows the map', () => {
const rated = [
mkPlace(1, { name: 'Top', rating_avg: 4.6 }),
mkPlace(2, { name: 'Fine', rating_avg: 3.2 }),
mkPlace(3, { name: 'Unrated' }),
]
const out = filterPool(rated, { filter: 'all', categoryFilters: new Set(), ratingFilter: 3, search: '', plannedIds })
expect(out.map(p => p.id)).toEqual([1, 2])
const all = filterPool(rated, { filter: 'all', categoryFilters: new Set(), search: '', plannedIds })
expect(all.map(p => p.id)).toEqual([1, 2, 3])
})
it('FE-MOB-PMODEL-013: poolCounts counts tracks on the category+search base set', () => {
const c = poolCounts(places, new Set(['4']), '', plannedIds)
expect(c.all).toBe(2)
@@ -1,5 +1,8 @@
import type { AssignmentsMap, Day, Place } from '../../../../types'
import { placeMatchesSearch } from '../../../../utils/placeSearch'
import {
matchesCategoryFilter, matchesPlacesFilter, type PlacesRatingFloor,
} from '../../../../utils/placesFilter'
import {
plannedPlaceIds as sharedPlannedPlaceIds,
type PlannedAccommodation, type PlannedReservation,
@@ -8,8 +11,10 @@ import {
/**
* Pure filter model of the mobile places browser. Mirrors the desktop
* sidebar's semantics exactly (usePlacesSidebar + the map's mapPlaces memo):
* the pool filter and category set come from the trip store, so the list here
* and the map markers always agree (#1541).
* the pool filter, the category set and the rating floor come from the trip
* store and go through the same matcher (utils/placesFilter) as the map markers
* (#1541); the map's own exceptions (open day, collapsed days) are described
* there.
*/
export function plannedPlaceIds(
@@ -38,12 +43,6 @@ export function firstPlannedDayNumbers(assignments: AssignmentsMap, days: Day[])
return result
}
export function matchesCategoryFilter(place: Place, categoryFilters: Set<string>): boolean {
if (categoryFilters.size === 0) return true
if (place.category_id == null) return categoryFilters.has('uncategorized')
return categoryFilters.has(String(place.category_id))
}
export function matchesSearch(place: Place, search: string): boolean {
return placeMatchesSearch(place, search)
}
@@ -51,17 +50,14 @@ export function matchesSearch(place: Place, search: string): boolean {
interface PoolFilterArgs {
filter: string
categoryFilters: Set<string>
/** Minimum average stars; omitted means every rating. */
ratingFilter?: PlacesRatingFloor
search: string
plannedIds: Set<number>
}
export function filterPool(places: Place[], { filter, categoryFilters, search, plannedIds }: PoolFilterArgs): Place[] {
return places.filter(p => {
if (filter === 'unplanned' && plannedIds.has(p.id)) return false
if (filter === 'planned' && !plannedIds.has(p.id)) return false
if (filter === 'tracks' && !p.route_geometry) return false
return matchesCategoryFilter(p, categoryFilters) && matchesSearch(p, search)
})
export function filterPool(places: Place[], { filter, categoryFilters, ratingFilter = 'all', search, plannedIds }: PoolFilterArgs): Place[] {
return places.filter(p => matchesPlacesFilter(p, { filter, categoryFilters, ratingFilter }, { plannedIds }) && matchesSearch(p, search))
}
/** Chip counts run on the category+search base set, like the desktop tabs. */
@@ -160,7 +160,7 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) {
<div
ref={cardRef}
data-touch-drag={editing ? '' : undefined}
className="absolute left-4 right-4 overflow-y-auto overscroll-contain rounded-[22px] border border-[color:var(--m-cbr)] bg-[color:var(--m-card)] px-3.5 pb-2 pt-1 backdrop-blur-[24px] backdrop-saturate-[1.6] bottom-[calc(env(safe-area-inset-bottom,0px)+90px)]"
className="absolute left-4 right-4 overflow-x-hidden overflow-y-auto overscroll-contain rounded-[22px] border border-[color:var(--m-cbr)] bg-[color:var(--m-card)] px-3.5 pb-2 pt-1 backdrop-blur-[24px] backdrop-saturate-[1.6] bottom-[calc(env(safe-area-inset-bottom,0px)+90px)]"
style={{ top: `calc(var(--m-safe-top, 12px) + ${editing ? 140 : tl.upNext ? 216 : 102}px)` }}
>
{planner.toursEnabled && tl.rows.some(row => row.kind === 'place' && row.invalidTour) && (
@@ -551,7 +551,7 @@ export function NoteRow({ note, chrome, reorder, drag, onEdit }: {
const { time: noteTime, detail } = splitNoteTime(note.time)
const time = noteTime ? fmtTime(noteTime, chrome) : ''
const [title, ...rest] = note.text.split('\n')
const titleExtra = rest.join(' ').trim()
const titleExtra = rest.join('\n').trim()
return (
<div
@@ -561,10 +561,10 @@ export function NoteRow({ note, chrome, reorder, drag, onEdit }: {
// A link in the rendered body keeps its own tap; the rest of the row edits.
onClick={chrome.editing ? (e => { if (!(e.target as HTMLElement).closest('a')) onEdit() }) : undefined}
onKeyDown={chrome.editing ? (e => { if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); onEdit() } }) : undefined}
className={`my-[2px] flex items-center gap-2.5 ${chrome.editing ? 'cursor-pointer' : ''} ${dragClass(drag)}`}
className={`my-[2px] flex items-start gap-2.5 ${chrome.editing ? 'cursor-pointer' : ''} ${dragClass(drag)}`}
>
{!chrome.editing && (
<AvatarRing style={note.color ? { background: skin.iconBackground, borderColor: skin.border } : undefined}>
<AvatarRing className="mt-[2px]" style={note.color ? { background: skin.iconBackground, borderColor: skin.border } : undefined}>
<Icon size={14} strokeWidth={2} style={{ color: skin.iconColor }} />
</AvatarRing>
)}
@@ -572,20 +572,20 @@ export function NoteRow({ note, chrome, reorder, drag, onEdit }: {
className="min-w-0 flex-1 rounded-[13px] border px-[11px] py-[7px]"
style={{ borderColor: skin.border, background: note.color ? skin.background : 'var(--m-ic)' }}
>
<div className="flex items-center gap-1.5">
<div className="flex min-w-0 items-start gap-1.5">
{time && <span className={TIME_CHIP}>{time}</span>}
<span className="min-w-0 text-[0.875rem] font-semibold">{title}</span>
<span className="min-w-0 text-[0.875rem] [overflow-wrap:anywhere] font-semibold">{title}</span>
</div>
{titleExtra && (
<div className="mt-px font-geist text-[0.71875rem] leading-[1.4] text-m-muted">{titleExtra}</div>
<MarkdownText className="mt-px font-geist text-[0.71875rem] leading-[1.4] text-m-muted">{titleExtra}</MarkdownText>
)}
{detail && (
// Rendered, not raw: a note written with the formatting bar would
// otherwise read as `**asterisks**` on the phone.
<MarkdownText className="mt-px font-geist text-[0.71875rem] leading-[1.45] text-m-muted [overflow-wrap:anywhere]">{detail}</MarkdownText>
<MarkdownText className="mt-px font-geist text-[0.71875rem] leading-[1.45] text-m-muted">{detail}</MarkdownText>
)}
</div>
{chrome.editing && <span className="flex flex-none items-center gap-1.5">{reorder}</span>}
{chrome.editing && <span className="mt-[2px] flex flex-none items-center gap-1.5">{reorder}</span>}
</div>
)
}
@@ -180,7 +180,7 @@ export default function MRoadtripTab({ planner, shell }: MTripTabPanelProps) {
{searchBar}
<div
ref={cardRef}
className={`absolute inset-0 overflow-y-auto overscroll-contain px-4 pb-[calc(var(--bottom-nav-h,84px)+22px)] ${
className={`absolute inset-0 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-[calc(var(--bottom-nav-h,84px)+22px)] ${
searchBar ? 'pt-[calc(var(--m-safe-top,12px)+150px)]' : 'pt-[calc(var(--m-safe-top,12px)+102px)]'
}`}
>
@@ -483,7 +483,7 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
{day.title || t('planner.dayN', { n: (day.day_number ?? planner.days.indexOf(day) + 1) || '?' })}
</div>
)}
<div className="whitespace-pre-wrap font-geist text-[0.75rem] leading-[1.5] text-m-muted">{assignment.notes}</div>
<div className="whitespace-pre-wrap [overflow-wrap:anywhere] font-geist text-[0.75rem] leading-[1.5] text-m-muted">{assignment.notes}</div>
</div>
))}
</div>
@@ -27,6 +27,7 @@ import MNoteSheet, { type MNoteSheetPayload } from './MNoteSheet'
import MImportSheet from './MImportSheet'
import MExportSheet from './MExportSheet'
import MMehrSheet from './MMehrSheet'
import MPlacesFilterSheet from '../places/MPlacesFilterSheet'
import MRtStopSheet from '../roadtrip/MRtStopSheet'
import MRtStaySheet from '../roadtrip/MRtStaySheet'
import MRtKindSheet from '../roadtrip/MRtKindSheet'
@@ -150,6 +151,13 @@ export default function MTripSheets({ planner, shell }: MTripSheetsProps) {
onClose={shell.closeSheet}
/>
<MImportSheet planner={planner} open={sheet?.id === 'import'} onClose={shell.closeSheet} />
<MPlacesFilterSheet
open={sheet?.id === 'placesFilter'}
onClose={shell.closeSheet}
places={planner.places}
categories={planner.categories}
toursEnabled={planner.toursEnabled}
/>
{/* ── Planner-flag editors (also serve ?create= and the import review) ── */}
<MPlaceEditSheet planner={planner} onOpenExpense={openBookingExpense} />
@@ -360,7 +360,7 @@ function NoteCardRow({ note, color, canEdit, onTap, onTogglePin, onDelete, t }:
<button type="button" onClick={onTap} className="block w-full px-3 pb-3 pt-[9px] text-left">
{note.content && (
<div className="line-clamp-3 font-geist text-[0.75rem] leading-[1.5] text-m-muted [&_a]:underline [&_ol]:list-decimal [&_ol]:pl-4 [&_p]:mb-1 [&_strong]:font-bold [&_ul]:list-disc [&_ul]:pl-4">
<div className="line-clamp-3 [overflow-wrap:anywhere] font-geist text-[0.75rem] leading-[1.5] text-m-muted [&_a]:underline [&_ol]:list-decimal [&_ol]:pl-4 [&_p]:mb-1 [&_strong]:font-bold [&_ul]:list-disc [&_ul]:pl-4">
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} rehypePlugins={sanitizedMarkdownPlugins} components={sanitizedMarkdownComponents}>{note.content}</Markdown>
</div>
)}
@@ -640,7 +640,7 @@ function NoteViewSheet({ open, note, onClose, t }: {
/>
<div className="min-h-0 flex-1 overflow-y-auto px-[18px] pb-4 pt-1">
{snapshot?.content && (
<div className="font-geist text-[0.8125rem] leading-[1.6] text-m-ink [&_a]:underline [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:mb-2 [&_strong]:font-bold [&_ul]:list-disc [&_ul]:pl-5">
<div className="font-geist text-[0.8125rem] leading-[1.6] text-m-ink [overflow-wrap:anywhere] [&_a]:underline [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:mb-2 [&_strong]:font-bold [&_ul]:list-disc [&_ul]:pl-5">
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} rehypePlugins={sanitizedMarkdownPlugins} components={sanitizedMarkdownComponents}>{snapshot.content}</Markdown>
</div>
)}
@@ -17,7 +17,7 @@ import { usePluginStore } from '../../../../store/pluginStore'
export function TabScroller({ children }: { children: ReactNode }) {
return (
<div className="flex h-full flex-col">
<div className="min-h-0 flex-1 overflow-y-auto px-4 pb-[calc(var(--bottom-nav-h,84px)+22px)] pt-[calc(var(--m-safe-top,12px)+58px)]">
<div className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 pb-[calc(var(--bottom-nav-h,84px)+22px)] pt-[calc(var(--m-safe-top,12px)+58px)]">
{children}
</div>
</div>