fix: make the app keyboard-reachable, and close four DoS-able patterns

The bulk of what SonarQube still had open on the reliability side, read site by
site rather than swept. Two clusters are worth calling out because they are
defects, not lint.

**Four regexes could be made to hang the process.** The worst is
`/.+@.+\..+/` in the forgot-password path: three unbounded `.+` that all
overlap, unanchored, on an endpoint that needs no login and whose schema is a
bare z.string() under a 100kb body cap. A thousand '@' characters had not
finished after 100 seconds — one request pins the event loop, and Node has one.
EMAIL_REGEX in auth.helpers is the same shape on register and profile update
(310ms for 8kb). The two tag strippers over an uploaded KML description and over
Commons metadata took 0.52s on a 16k run of '<'. Each rewrite was proven
equivalent by brute force against the original — millions of strings for the
coordinate patterns, 671,876 for the tag stripper — because a subtly different
regex on a parsing path is worse than the finding.

`<[^>]+>` could not be fixed in the pattern: `[^>]` matches `<` too, so the only
unambiguous form changes what happens to malformed markup. It is now a scan in
common/stripHtmlTags.ts, quirks included — `<>` is left alone, `<a<b>` is one
tag — with the equivalence pinned by a test that compares against the old regex
over every string up to length six.

**And roughly 500 places could only be reached with a mouse.** Clickable divs
became real buttons where the markup allowed (52 of them), took
role + tabIndex + Enter/Space where they had to stay divs, and modal backdrops
took role="presentation" — the honest role, since a backdrop is a mouse shortcut
for a Cancel control that is already in the tab order, and making it a button
plants a nameless full-screen tab stop around its own contents.

Alongside those: `.sort()` calls that now say the order they always had, `{n &&
<X/>}` guards that rendered a literal "0" for a zero-byte file and for a place at
latitude 0, an optimistic budget write that stored a boolean where the contract
and both transports use 0/1, and the Number statics.

sonar-project.properties documents the six that were deliberately left: two wiki
patterns with no overlapping quantifier pair whose "fix" would stop parsing
`[see [1]](url)`, four tar header fields bounded at 12-155 bytes by the format,
two djb2 hashes where the 32-bit wrap is the algorithm, two `| 0` that are also
coercing undefined to 0 on a path where the API sends no user_id, and the MCP
session maps Sonar reads as empty because they are filled from another module.
This commit is contained in:
Maurice
2026-08-25 18:28:40 +02:00
committed by Maurice
parent 52d1a0720f
commit 1ad2e92142
225 changed files with 1721 additions and 735 deletions
+8 -8
View File
@@ -170,9 +170,9 @@ function AtlasPageDesktop(): React.ReactElement {
{/* Country action popup */}
{confirmAction && (
<div className="bg-[rgba(0,0,0,0.4)]" style={{ position: 'fixed', inset: 0, zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 20 }}
<div role="presentation" className="bg-[rgba(0,0,0,0.4)]" style={{ position: 'fixed', inset: 0, zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 20 }}
onClick={() => setConfirmAction(null)}>
<div className="bg-surface-card" style={{ borderRadius: 16, padding: 24, maxWidth: 340, width: '100%', boxShadow: '0 16px 48px rgba(0,0,0,0.2)', textAlign: 'center' }}
<div role="presentation" className="bg-surface-card" style={{ borderRadius: 16, padding: 24, maxWidth: 340, width: '100%', boxShadow: '0 16px 48px rgba(0,0,0,0.2)', textAlign: 'center' }}
onClick={e => e.stopPropagation()}>
{confirmAction.code.length === 2 ? (
<img src={`https://flagcdn.com/w80/${confirmAction.code.toLowerCase()}.png`} alt={confirmAction.code} style={{ width: 48, height: 34, borderRadius: 6, objectFit: 'cover', marginBottom: 12, display: 'inline-block' }} />
@@ -202,7 +202,7 @@ function AtlasPageDesktop(): React.ReactElement {
<div className="text-content-muted" style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', marginTop: 1 }}>{t('atlas.markVisitedHint')}</div>
</div>
</button>
<button onClick={() => setConfirmAction({ ...confirmAction, type: 'bucket' as any })}
<button type="button" onClick={() => setConfirmAction({ ...confirmAction, type: 'bucket' as any })}
className="border border-edge"
style={{ display: 'flex', alignItems: 'center', gap: 10, width: '100%', padding: '12px 16px', borderRadius: 12, background: 'none', cursor: 'pointer', fontFamily: 'inherit', textAlign: 'left', transition: 'background 0.12s' }}
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-secondary)'}
@@ -241,7 +241,7 @@ function AtlasPageDesktop(): React.ReactElement {
{confirmAction.countryName && (
<p className="text-content-muted" style={{ margin: '-8px 0 8px', fontSize: 'calc(12px * var(--fs-scale-body, 1))' }}>{confirmAction.countryName}</p>
)}
<button onClick={async () => {
<button type="button" onClick={async () => {
const { code: countryCode, name: rName, regionCode: rCode } = confirmAction
if (!rCode) return
try {
@@ -267,7 +267,7 @@ function AtlasPageDesktop(): React.ReactElement {
<div className="text-content-muted" style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', marginTop: 1 }}>{t('atlas.markRegionVisitedHint')}</div>
</div>
</button>
<button onClick={() => setConfirmAction({ ...confirmAction, type: 'bucket' })}
<button type="button" onClick={() => setConfirmAction({ ...confirmAction, type: 'bucket' })}
className="border border-edge"
style={{ display: 'flex', alignItems: 'center', gap: 10, width: '100%', padding: '12px 16px', borderRadius: 12, background: 'none', cursor: 'pointer', fontFamily: 'inherit', textAlign: 'left', transition: 'background 0.12s' }}
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-secondary)'}
@@ -311,7 +311,7 @@ function AtlasPageDesktop(): React.ReactElement {
style={{ padding: '8px 20px', borderRadius: 10, background: 'none', fontSize: 'calc(13px * var(--fs-scale-body, 1))', cursor: 'pointer', fontFamily: 'inherit' }}>
{t('common.cancel')}
</button>
<button onClick={async () => {
<button type="button" onClick={async () => {
const { code: countryCode, regionCode: rCode } = confirmAction
if (!rCode) return
try {
@@ -386,7 +386,7 @@ function AtlasPageDesktop(): React.ReactElement {
</div>
</div>
<div style={{ display: 'flex', gap: 8, justifyContent: 'center', flexWrap: 'wrap' }}>
<button onClick={() => setConfirmAction({ ...confirmAction, type: confirmAction.regionCode ? 'choose-region' : 'choose' })}
<button type="button" onClick={() => setConfirmAction({ ...confirmAction, type: confirmAction.regionCode ? 'choose-region' : 'choose' })}
className="border border-edge text-content-muted"
style={{ padding: '8px 20px', borderRadius: 10, background: 'none', fontSize: 'calc(13px * var(--fs-scale-body, 1))', cursor: 'pointer', fontFamily: 'inherit' }}>
{t('common.back')}
@@ -586,7 +586,7 @@ function SidebarContent({ data, stats, countries, selectedCountry, countryDetail
</button>
)}
{bucketForm.name && (
<button onClick={() => { setBucketForm({ ...bucketForm, name: '', lat: '', lng: '' }); setBucketSearch('') }}
<button type="button" onClick={() => { setBucketForm({ ...bucketForm, name: '', lat: '', lng: '' }); setBucketSearch('') }}
className="border border-edge text-content-faint"
style={{ padding: '6px 8px', borderRadius: 8, background: 'none', cursor: 'pointer', display: 'flex', alignItems: 'center' }}>
<X size={12} />
+1 -1
View File
@@ -294,7 +294,7 @@ function CollectionsPageDesktop(): React.ReactElement {
{/* Mobile rail drawer */}
{c.mobileRailOpen && (
<>
<div className="col-drawer-backdrop" onClick={() => c.setMobileRailOpen(false)} />
<div role="presentation" className="col-drawer-backdrop" onClick={() => c.setMobileRailOpen(false)} />
<div className="col-drawer">
<div className="col-drawer-head">
<button type="button" onClick={() => c.setMobileRailOpen(false)} aria-label={t('common.close')}><X size={18} /></button>
+22 -8
View File
@@ -52,7 +52,7 @@ function tripGradient(id: number): string { return GRADIENTS[id % GRADIENTS.leng
function splitDate(dateStr: string | null | undefined, locale: string): { d: string; m: string; y: string } | null {
if (!dateStr) return null
const date = new Date(dateStr + 'T00:00:00Z')
if (isNaN(date.getTime())) return null // malformed date — render a dash, never crash
if (Number.isNaN(date.getTime())) return null // malformed date — render a dash, never crash
const otherYear = date.getUTCFullYear() !== new Date().getUTCFullYear()
return {
d: date.toLocaleDateString(locale, { day: 'numeric', timeZone: 'UTC' }),
@@ -67,7 +67,7 @@ function splitDate(dateStr: string | null | undefined, locale: string): { d: str
function fullDate(dateStr: string | null | undefined, locale: string): string | null {
if (!dateStr) return null
const date = new Date(dateStr + 'T00:00:00Z')
if (isNaN(date.getTime())) return null
if (Number.isNaN(date.getTime())) return null
const opts: Intl.DateTimeFormatOptions = { day: 'numeric', month: 'short', timeZone: 'UTC' }
if (date.getUTCFullYear() !== new Date().getUTCFullYear()) opts.year = 'numeric'
return date.toLocaleDateString(locale, opts)
@@ -393,7 +393,13 @@ function BoardingPassHero({ trip, bundle, locale, onOpen, onEdit, onCopy, onArch
)
return (
<section className="hero-trip" onClick={onOpen}>
<div
className="hero-trip"
onClick={onOpen}
role="button"
tabIndex={0}
onKeyDown={(e) => { if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); onOpen() } }}
>
{trip.cover_image
? <img className="bg" src={trip.cover_image} alt={trip.title} />
: <div className="bg" style={{ background: tripGradient(trip.id) }} />}
@@ -424,12 +430,12 @@ function BoardingPassHero({ trip, bundle, locale, onOpen, onEdit, onCopy, onArch
))}
</div>
)}
<div className="hero-pass" onClick={(e) => { e.stopPropagation(); onOpen() }}>
<div className="hero-pass" role="presentation" onClick={(e) => { e.stopPropagation(); onOpen() }}>
<div className="hero-pass-inner">{passCells}</div>
</div>
</div>
</div>
</section>
</div>
)
}
@@ -552,7 +558,13 @@ function TripCard({ trip, locale, badges, onOpen, onEdit, onCopy, onArchive, onD
const stop = (e: React.MouseEvent, fn: () => void) => { e.stopPropagation(); fn() }
return (
<article className="trip-card" onClick={onOpen}>
<div
className="trip-card"
onClick={onOpen}
role="button"
tabIndex={0}
onKeyDown={(e) => { if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); onOpen() } }}
>
<div className="trip-cover">
{trip.cover_image
? <img src={trip.cover_image} alt={trip.title} />
@@ -585,7 +597,7 @@ function TripCard({ trip, locale, badges, onOpen, onEdit, onCopy, onArchive, onD
</div>
<TripCardBadges items={badges ?? []} />
</div>
</article>
</div>
)
}
@@ -793,7 +805,9 @@ function UpcomingTool({ items, locale, onOpen }: {
const timeStr = parsed.time ? formatTime(parsed.time, locale, timeFormat) : null
const typeClass = RES_TYPE_CLASS[r.type] || 'other'
return (
<div className="upc-item" key={r.id} onClick={() => onOpen(r.trip_id)}>
<div className="upc-item" key={r.id} onClick={() => onOpen(r.trip_id)}
role="button" tabIndex={0}
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onOpen(r.trip_id) } }}>
<div className="upc-date"><div className="d mono">{dateStr?.d ?? '–'}</div><div className="m">{dateStr?.m ?? ''}</div></div>
<div className="upc-info">
<div className="t">{r.title}</div>
+2 -1
View File
@@ -99,10 +99,11 @@ export default function HelpPage() {
{/* Mobile sidebar drawer */}
{navOpen && (
<div className="lg:hidden fixed inset-0 z-[120]" onClick={() => setNavOpen(false)}>
<div className="lg:hidden fixed inset-0 z-[120]" role="presentation" onClick={() => setNavOpen(false)}>
<div className="absolute inset-0 bg-black/40" />
<div
className="absolute left-0 top-0 bottom-0 w-[280px] bg-surface-card p-5 overflow-y-auto shadow-xl"
role="presentation"
onClick={(e) => e.stopPropagation()}
>
<div className="flex items-center justify-between mb-4">
+23 -13
View File
@@ -122,9 +122,10 @@ function JourneyPageDesktop() {
{/* Active Journey Hero */}
{activeJourney && (
<div className="mb-10">
<div
<button
type="button"
onClick={() => navigate(`/journey/${activeJourney.id}`)}
className="relative rounded-[28px] overflow-hidden cursor-pointer h-[250px] md:h-[280px] transition-transform duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] hover:-translate-y-1 shadow-[0_2px_4px_rgba(0,0,0,0.06),0_20px_48px_-18px_rgba(0,0,0,0.32)]"
className="block w-full text-left relative rounded-[28px] overflow-hidden cursor-pointer h-[250px] md:h-[280px] transition-transform duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] hover:-translate-y-1 shadow-[0_2px_4px_rgba(0,0,0,0.06),0_20px_48px_-18px_rgba(0,0,0,0.32)]"
style={{
background: activeJourney.cover_image
? `linear-gradient(120deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.15) 45%, rgba(0,0,0,0.05) 100%), url(/uploads/${activeJourney.cover_image}) center/cover`
@@ -188,7 +189,7 @@ function JourneyPageDesktop() {
</div>
</div>
</div>
</div>
</button>
</div>
)}
@@ -283,16 +284,24 @@ function JourneyPageDesktop() {
upcoming: 'bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400',
}
const toggleTrip = () => {
setSelectedTripIds(prev => {
const next = new Set(prev)
if (next.has(trip.id)) next.delete(trip.id)
else next.add(trip.id)
return next
})
}
return (
<div
key={trip.id}
onClick={() => {
setSelectedTripIds(prev => {
const next = new Set(prev)
if (next.has(trip.id)) next.delete(trip.id)
else next.add(trip.id)
return next
})
role="checkbox"
aria-checked={selected}
tabIndex={0}
onClick={toggleTrip}
onKeyDown={e => {
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggleTrip() }
}}
className={`flex items-center gap-3 p-3 rounded-xl border cursor-pointer transition-[border-color,background-color] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] ${
selected
@@ -366,9 +375,10 @@ function JourneyCard({ journey, onClick }: { journey: Journey & { entry_count?:
const lifecycle = computeJourneyLifecycle(j.status, j.trip_date_min, j.trip_date_max)
return (
<div
<button
type="button"
onClick={onClick}
className="vg-card rounded-[24px] overflow-hidden cursor-pointer transition-[transform,box-shadow] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] hover:-translate-y-1 flex flex-col"
className="vg-card w-full text-left rounded-[24px] overflow-hidden cursor-pointer transition-[transform,box-shadow] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] hover:-translate-y-1 flex flex-col"
>
{/* Cover with title overlay */}
<div className="relative h-[200px] overflow-hidden" style={{ background: pickGradient(j.id) }}>
@@ -415,6 +425,6 @@ function JourneyCard({ journey, onClick }: { journey: Journey & { entry_count?:
))}
</div>
</div>
</div>
</button>
)
}
+43 -18
View File
@@ -241,8 +241,9 @@ export default function JourneyPublicPage() {
>
{/* Photo area */}
{photos.length === 1 && (
<div
className="relative cursor-pointer"
<button
type="button"
className="relative block w-full cursor-pointer text-left"
onClick={() => setLightbox({ photos: lightboxPhotos, index: 0 })}
>
<img src={photoUrl(photos[0], token!)} className="h-64 w-full object-cover" alt="" />
@@ -269,26 +270,32 @@ export default function JourneyPublicPage() {
</h3>
</div>
)}
</div>
</button>
)}
{photos.length === 2 && (
<div className="grid grid-cols-2 gap-0.5 overflow-hidden">
{photos.slice(0, 2).map((p, i) => (
<img
<button
key={p.id}
src={photoUrl(p, token!, 'thumbnail')}
alt=""
className="h-52 w-full cursor-pointer object-cover"
type="button"
className="block h-52 w-full cursor-pointer overflow-hidden"
onClick={() => setLightbox({ photos: lightboxPhotos, index: i })}
/>
>
<img
src={photoUrl(p, token!, 'thumbnail')}
alt=""
className="h-full w-full object-cover"
/>
</button>
))}
</div>
)}
{photos.length >= 3 && (
<div className="flex overflow-hidden" style={{ height: 280, gap: 2 }}>
<div
<button
type="button"
className="min-w-0 flex-1 cursor-pointer"
onClick={() => setLightbox({ photos: lightboxPhotos, index: 0 })}
>
@@ -297,9 +304,10 @@ export default function JourneyPublicPage() {
alt=""
className="h-full w-full object-cover"
/>
</div>
</button>
<div className="flex min-w-0 flex-1 flex-col" style={{ gap: 2 }}>
<div
<button
type="button"
className="min-h-0 flex-1 cursor-pointer"
onClick={() => setLightbox({ photos: lightboxPhotos, index: 1 })}
>
@@ -308,8 +316,9 @@ export default function JourneyPublicPage() {
alt=""
className="h-full w-full object-cover"
/>
</div>
<div
</button>
<button
type="button"
className="relative min-h-0 flex-1 cursor-pointer"
onClick={() => setLightbox({ photos: lightboxPhotos, index: 2 })}
>
@@ -325,13 +334,27 @@ export default function JourneyPublicPage() {
</span>
</div>
)}
</div>
</button>
</div>
</div>
)}
{/* Content */}
<div className="cursor-pointer px-5 pb-5 pt-4" onClick={() => setViewingEntry(entry)}>
{/* Stays a div: the story renders user markdown, links included,
and a link may not sit inside a <button>. */}
<div
role="button"
tabIndex={0}
className="cursor-pointer px-5 pb-5 pt-4"
onClick={() => setViewingEntry(entry)}
onKeyDown={(e) => {
if (e.target !== e.currentTarget) return;
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
setViewingEntry(entry);
}
}}
>
{/* Title (only when no single photo — photo has it in overlay) */}
{photos.length !== 1 && entry.title && (
<h3 className="mb-2 text-[16px] font-semibold leading-snug tracking-tight text-zinc-900 dark:text-white">
@@ -458,9 +481,10 @@ export default function JourneyPublicPage() {
const renderGallery = () => (
<div className="grid grid-cols-2 gap-1.5 sm:grid-cols-3 md:grid-cols-4">
{allPhotos.map((photo, idx) => (
<div
<button
key={photo.id}
className="relative aspect-square cursor-pointer overflow-hidden rounded-lg"
type="button"
className="relative block aspect-square w-full cursor-pointer overflow-hidden rounded-lg"
onClick={() =>
setLightbox({
photos: allPhotos.map((p) => ({
@@ -486,7 +510,7 @@ export default function JourneyPublicPage() {
</span>
</div>
)}
</div>
</button>
))}
</div>
);
@@ -594,6 +618,7 @@ export default function JourneyPublicPage() {
>
{SUPPORTED_LANGUAGES.map((lang) => (
<button
type="button"
key={lang.value}
onClick={() => {
useSettingsStore.setState((s) => ({ settings: { ...s.settings, language: lang.value } }));
+11
View File
@@ -265,7 +265,12 @@ export default function LoginPage(): React.ReactElement {
<div
role="listbox"
aria-label="Select language"
tabIndex={-1}
/* Both handlers do the one job: keep the event from reaching the
document listener that closes the dropdown. The options below are
real buttons and carry the keyboard interaction themselves. */
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => e.stopPropagation()}
style={{
position: 'absolute',
top: '100%',
@@ -934,7 +939,13 @@ export default function LoginPage(): React.ReactElement {
onToggle={() => setRememberMe(!rememberMe)}
label={t('login.rememberMe')}
/>
{/* The visible caption repeats the switch's own aria-label and
clicking it is a mouse shortcut for hitting the switch.
Hidden from assistive tech so it does not read out as a
second "Remember me" control: the switch above is the one
that carries the name, the focus and the keyboard. */}
<span
aria-hidden="true"
onClick={() => setRememberMe(!rememberMe)}
style={{
cursor: 'pointer',
+6 -2
View File
@@ -506,7 +506,9 @@ describe('SharedTripPage', () => {
// the day picker above the map was added (#1962): once as a chip, once on the card.
await waitFor(() => expect(screen.getAllByText('Tag 1')).toHaveLength(2));
const labels = screen.getAllByText('Tag 1');
expect(labels.filter((el) => el.closest('button'))).toHaveLength(1);
// One of each: the picker chip carries aria-pressed, the day card's header aria-expanded.
expect(labels.filter((el) => el.closest('[aria-pressed]'))).toHaveLength(1);
expect(labels.filter((el) => el.closest('[aria-expanded]'))).toHaveLength(1);
});
});
@@ -709,7 +711,9 @@ describe('SharedTripPage', () => {
// Twice since the day picker landed (#1962): the chip above the map and the card.
const dayLabels = screen.getAllByText('Day 1');
expect(dayLabels).toHaveLength(2);
expect(dayLabels.filter((el) => el.closest('button'))).toHaveLength(1);
// One of each: the picker chip carries aria-pressed, the day card's header aria-expanded.
expect(dayLabels.filter((el) => el.closest('[aria-pressed]'))).toHaveLength(1);
expect(dayLabels.filter((el) => el.closest('[aria-expanded]'))).toHaveLength(1);
expect(screen.getByText('Hotel Lutetia')).toBeInTheDocument();
expect(screen.getByText('0 places')).toBeInTheDocument();
// No date row for an undated day.
+13 -3
View File
@@ -360,6 +360,7 @@ export default function SharedTripPage() {
>
{SUPPORTED_LANGUAGES.map((lang) => (
<button
type="button"
key={lang.value}
onClick={() => {
// Set language locally without API call (shared page has no auth)
@@ -540,14 +541,21 @@ export default function SharedTripPage() {
className="border border-edge-faint bg-surface-card"
style={{ borderRadius: 14, overflow: 'hidden' }}
>
<div
<button
type="button"
onClick={() => setSelectedDay(selectedDay === day.id ? null : day.id)}
aria-expanded={selectedDay === day.id}
style={{
padding: '12px 16px',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
gap: 10,
width: '100%',
background: 'none',
border: 'none',
textAlign: 'left',
fontFamily: 'inherit',
}}
>
<div
@@ -632,7 +640,7 @@ export default function SharedTripPage() {
>
{dayPlaceCount} {t('shared.places')}
</span>
</div>
</button>
{selectedDay === day.id && merged.length > 0 && (
<div style={{ padding: '0 16px 12px', display: 'flex', flexDirection: 'column', gap: 6 }}>
@@ -796,6 +804,7 @@ export default function SharedTripPage() {
{place.image_url ? (
<img
src={place.image_url}
alt=""
style={{ width: 28, height: 28, borderRadius: '50%', objectFit: 'cover' }}
/>
) : (
@@ -1099,7 +1108,7 @@ export default function SharedTripPage() {
style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 600 }}
>
{item.total_price
? `${convert(parseFloat(item.total_price) || 0, curOf(item)).toLocaleString(locale, { minimumFractionDigits: 2 })} ${base}`
? `${convert(Number.parseFloat(item.total_price) || 0, curOf(item)).toLocaleString(locale, { minimumFractionDigits: 2 })} ${base}`
: '—'}
</span>
</div>
@@ -1183,6 +1192,7 @@ export default function SharedTripPage() {
{msg.avatar ? (
<img
src={avatarSrc(msg.avatar)!}
alt=""
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/>
) : (
+6 -4
View File
@@ -502,6 +502,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
/>
{!leftCollapsed && (
<div
role="presentation"
onMouseDown={startResizeLeft}
style={{ position: 'absolute', right: 0, top: 0, bottom: 0, width: 4, cursor: 'col-resize', background: 'transparent' }}
onMouseEnter={e => e.currentTarget.style.background = 'rgba(0,0,0,0.08)'}
@@ -539,6 +540,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
}}>
{!rightCollapsed && (
<div
role="presentation"
onMouseDown={startResizeRight}
style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 4, cursor: 'col-resize', background: 'transparent' }}
onMouseEnter={e => e.currentTarget.style.background = 'rgba(0,0,0,0.08)'}
@@ -653,8 +655,8 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
)}
{selectedPlace && isMobile && createPortal(
<div className="bg-[rgba(0,0,0,0.3)]" style={{ position: 'fixed', inset: 0, zIndex: 9999, display: 'flex', alignItems: 'flex-end', justifyContent: 'center', paddingBottom: 'var(--bottom-nav-h)' }} onClick={() => setSelectedPlaceId(null)}>
<div style={{ width: '100%', maxHeight: '85vh' }} onClick={e => e.stopPropagation()}>
<div className="bg-[rgba(0,0,0,0.3)]" style={{ position: 'fixed', inset: 0, zIndex: 9999, display: 'flex', alignItems: 'flex-end', justifyContent: 'center', paddingBottom: 'var(--bottom-nav-h)' }} role="presentation" onClick={() => setSelectedPlaceId(null)}>
<div style={{ width: '100%', maxHeight: '85vh' }} role="presentation" onClick={e => e.stopPropagation()}>
<PlaceInspector
onEditTransport={openLinkedTransport}
onEditReservation={openLinkedReservation}
@@ -698,8 +700,8 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
)}
{mobileSidebarOpen && createPortal(
<div className="bg-[rgba(0,0,0,0.3)]" style={{ position: 'fixed', inset: 0, zIndex: 9999 }} onClick={() => setMobileSidebarOpen(null)}>
<div className="bg-surface-card" style={{ position: 'absolute', top: 'var(--nav-h)', left: 0, right: 0, bottom: 0, display: 'flex', flexDirection: 'column', overflow: 'hidden' }} onClick={e => e.stopPropagation()}>
<div className="bg-[rgba(0,0,0,0.3)]" style={{ position: 'fixed', inset: 0, zIndex: 9999 }} role="presentation" onClick={() => setMobileSidebarOpen(null)}>
<div className="bg-surface-card" style={{ position: 'absolute', top: 'var(--nav-h)', left: 0, right: 0, bottom: 0, display: 'flex', flexDirection: 'column', overflow: 'hidden' }} role="presentation" onClick={e => e.stopPropagation()}>
<div className="border-b border-edge-secondary" style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '14px 16px' }}>
<span className="text-content" style={{ fontWeight: 600, fontSize: 'calc(14px * var(--fs-scale-body, 1))' }}>{mobileSidebarOpen === 'left' ? t('trip.mobilePlan') : t('trip.mobilePlaces')}</span>
<button type="button" onClick={() => setMobileSidebarOpen(null)} className="bg-surface-tertiary text-content" style={{ border: 'none', borderRadius: '50%', width: 28, height: 28, cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+6 -4
View File
@@ -67,7 +67,8 @@ function VacayPageDesktop(): React.ReactElement {
</div>
<div className="grid grid-cols-4 gap-1.5">
{years.map(y => (
<div key={y} onClick={() => setSelectedYear(y)}
<div key={y} role="button" tabIndex={0} onClick={() => setSelectedYear(y)}
onKeyDown={e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setSelectedYear(y) } }}
className="group relative rounded-[9px] text-center cursor-pointer transition-[background-color,color] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]"
style={{
padding: '7px 0',
@@ -78,10 +79,11 @@ function VacayPageDesktop(): React.ReactElement {
}}>
{y}
{years.length > 1 && (
<span onClick={e => { e.stopPropagation(); setDeleteYear(y); setShowMobileSidebar(false) }}
<button type="button" aria-label={t('vacay.removeYear')}
onClick={e => { e.stopPropagation(); setDeleteYear(y); setShowMobileSidebar(false) }}
className="absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-red-500 text-white text-[7px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer">
<Minus size={7} />
</span>
</button>
)}
</div>
))}
@@ -168,7 +170,7 @@ function VacayPageDesktop(): React.ReactElement {
{/* Mobile Sidebar Drawer */}
{showMobileSidebar && createPortal(
<div className="fixed inset-0 lg:hidden" style={{ zIndex: 99980 }}>
<div className="absolute inset-0 bg-[rgba(0,0,0,0.4)]" onClick={() => setShowMobileSidebar(false)} />
<div className="absolute inset-0 bg-[rgba(0,0,0,0.4)]" role="presentation" onClick={() => setShowMobileSidebar(false)} />
<div className="absolute left-0 top-0 bottom-0 w-[280px] overflow-y-auto p-3 flex flex-col gap-3 bg-surface"
style={{ boxShadow: '4px 0 24px rgba(0,0,0,0.15)', animation: 'slideInLeft 0.2s ease-out' }}>
{sidebarContent}
@@ -101,7 +101,7 @@ export default function AdminNotificationsTab({ admin, t }: AdminNotificationsTa
<span className="text-xs font-medium text-slate-500">Skip TLS certificate check</span>
<p className="text-[10px] text-slate-400 mt-0.5">Enable for self-signed certificates on local mail servers</p>
</div>
<button onClick={() => {
<button type="button" onClick={() => {
const newVal = smtpValues.smtp_skip_tls_verify === 'true' ? 'false' : 'true'
setSmtpValues(prev => ({ ...prev, smtp_skip_tls_verify: newVal }))
}}
@@ -193,7 +193,7 @@ export default function AdminNotificationsTab({ admin, t }: AdminNotificationsTa
<h2 className="font-semibold text-slate-900">{t('admin.notifications.tripReminders.title')}</h2>
<p className="text-xs text-slate-400 mt-1">{t('admin.notifications.tripReminders.hint')}</p>
</div>
<button
<button type="button"
onClick={async () => {
const next = !tripRemindersActive
setSmtpValues(prev => ({ ...prev, notify_trip_reminder: next ? 'true' : 'false' }))
@@ -312,7 +312,7 @@ export default function AdminNotificationsTab({ admin, t }: AdminNotificationsTa
className="flex-1 px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"
/>
{smtpValues.admin_ntfy_token === '••••••••' && (
<button
<button type="button"
onClick={async () => {
try {
await authApi.updateAppSettings({ admin_ntfy_token: '' })
+6 -3
View File
@@ -496,8 +496,9 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
<p className="text-xs text-slate-400 mt-1">{t('admin.oidcIssuerHint')}</p>
</div>
<div>
<label className="block text-sm font-medium text-slate-700 mb-1.5">Discovery URL <span className="text-slate-400 font-normal">(optional)</span></label>
<label htmlFor="oidc-discovery-url" className="block text-sm font-medium text-slate-700 mb-1.5">Discovery URL <span className="text-slate-400 font-normal">(optional)</span></label>
<input
id="oidc-discovery-url"
type="url"
value={oidcConfig.discovery_url}
onChange={e => setOidcConfig(c => ({ ...c, discovery_url: e.target.value }))}
@@ -507,8 +508,9 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
<p className="text-xs text-slate-400 mt-1">Override the auto-constructed discovery URL. Required for providers like Authentik where the endpoint is not at <code className="bg-slate-100 px-1 rounded">{'<issuer>/.well-known/openid-configuration'}</code>.</p>
</div>
<div>
<label className="block text-sm font-medium text-slate-700 mb-1.5">Client ID</label>
<label htmlFor="oidc-client-id" className="block text-sm font-medium text-slate-700 mb-1.5">Client ID</label>
<input
id="oidc-client-id"
type="text"
value={oidcConfig.client_id}
onChange={e => setOidcConfig(c => ({ ...c, client_id: e.target.value }))}
@@ -516,8 +518,9 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
/>
</div>
<div>
<label className="block text-sm font-medium text-slate-700 mb-1.5">Client Secret</label>
<label htmlFor="oidc-client-secret" className="block text-sm font-medium text-slate-700 mb-1.5">Client Secret</label>
<input
id="oidc-client-secret"
type="password"
value={oidcConfig.client_secret}
onChange={e => setOidcConfig(c => ({ ...c, client_secret: e.target.value }))}
@@ -244,9 +244,11 @@ export default function AdminUserModals({ admin, t }: AdminUserModalsProps): Rea
justifyContent: 'center',
padding: 16,
}}
role="presentation"
onClick={() => setShowUpdateModal(false)}
>
<div
role="presentation"
onClick={(e) => e.stopPropagation()}
style={{ width: '100%', maxWidth: 440, borderRadius: 16, overflow: 'hidden' }}
className="border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800"
+5 -3
View File
@@ -116,7 +116,9 @@ export function normalizeRegionName(name: string): string {
return name
.normalize('NFD').replace(/[̀-ͯ]/g, '') // strip combining diacritics
.replace(/[‐-―]/g, '-') // fold hyphen/dash variants to "-"
.replace(/\s*-\s*/g, '-') // collapse spaced dashes ("A – B" vs "A-B")
// Collapse spaced dashes ("A – B" vs "A-B"). split/trim, not /\s*-\s*/g:
// that pattern backtracks over every space in a dash-less name (quadratic).
.split('-').map(part => part.trim()).join('-')
.toLowerCase()
.trim()
}
@@ -180,7 +182,7 @@ export const COUNTRY_COLORS = ['#6366f1', '#ec4899', '#14b8a6', '#f97316', '#8b5
// every other country's color each time one more was marked or added.
export function countryColor(a3: string): string {
let hash = 0
for (let i = 0; i < a3.length; i++) hash = (hash * 31 + a3.charCodeAt(i)) >>> 0
for (let i = 0; i < a3.length; i++) hash = (hash * 31 + a3.codePointAt(i)) >>> 0
return COUNTRY_COLORS[hash % COUNTRY_COLORS.length]
}
@@ -214,7 +216,7 @@ export function regionCacheEvictions(order: string[], keep: Set<string>, max: nu
// Convert country code to flag emoji
export function countryCodeToFlag(code: string): string {
if (!code || code.length !== 2) return ''
return String.fromCodePoint(...[...code.toUpperCase()].map(c => 0x1F1E6 + c.charCodeAt(0) - 65))
return String.fromCodePoint(...[...code.toUpperCase()].map(c => 0x1F1E6 + c.codePointAt(0) - 65))
}
// ISO-3166-1 alpha-2 → alpha-3 mapping. Two sources feed this table: