mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 17:26:24 +00:00
fix(quality): resolve reliability findings on dev
The Sonar quality gate rated new code D. Preserve focus and keyboard interaction through native controls and shared dialog behavior. Replace ambiguous regex scans with bounded parsing and make numeric coercion and initialization explicit.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { Plus, Trash2, Pencil, Package, X, Check, ChevronRight, FolderPlus, Loader2 } from 'lucide-react'
|
||||
import { fs } from '../shared/DialogShell'
|
||||
@@ -57,7 +58,7 @@ export default function PackingTemplateManager() {
|
||||
{showCreate && (
|
||||
<div className={COMPOSER_ROW} style={{ boxShadow: COMPOSER.boxShadow }}>
|
||||
<Package size={15} className="flex-none text-content-faint" />
|
||||
<input autoFocus value={createName} onChange={e => setCreateName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={createName} onChange={e => setCreateName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleCreateTemplate(); if (e.key === 'Escape') setShowCreate(false) }}
|
||||
placeholder={t('admin.packingTemplates.namePlaceholder')} className={COMPOSER_INPUT} style={fs(13, 'body')} />
|
||||
<Tooltip label={t('common.save')}>
|
||||
@@ -101,7 +102,7 @@ export default function PackingTemplateManager() {
|
||||
<Package size={15} strokeWidth={1.9} />
|
||||
</span>
|
||||
{editingTemplate === tmpl.id ? (
|
||||
<input autoFocus value={editTemplateName} onChange={e => setEditTemplateName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={editTemplateName} onChange={e => setEditTemplateName(e.target.value)}
|
||||
onBlur={() => handleRenameTemplate(tmpl.id)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleRenameTemplate(tmpl.id); if (e.key === 'Escape') setEditingTemplate(null) }}
|
||||
aria-label={t('common.rename')}
|
||||
@@ -132,7 +133,7 @@ export default function PackingTemplateManager() {
|
||||
{/* Category header */}
|
||||
<div data-row="category" className="flex items-center gap-1.5 border-b border-edge-faint bg-surface-tertiary py-1.5 ps-3 pe-1.5">
|
||||
{editingCatId === cat.id ? (
|
||||
<input autoFocus value={editCatName} onChange={e => setEditCatName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={editCatName} onChange={e => setEditCatName(e.target.value)}
|
||||
onBlur={() => handleRenameCategory(cat.id)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleRenameCategory(cat.id); if (e.key === 'Escape') setEditingCatId(null) }}
|
||||
aria-label={t('common.rename')}
|
||||
@@ -162,7 +163,7 @@ export default function PackingTemplateManager() {
|
||||
<div key={item.id} data-row="item" className="group flex min-h-[40px] items-center gap-2 py-1.5 ps-3 pe-1.5">
|
||||
{editingItemId === item.id ? (
|
||||
<>
|
||||
<input autoFocus value={editItemName} onChange={e => setEditItemName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={editItemName} onChange={e => setEditItemName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleRenameItem(item.id); if (e.key === 'Escape') setEditingItemId(null) }}
|
||||
aria-label={t('common.rename')}
|
||||
className={`${ROW_INPUT} flex-1`} style={fs(12.5, 'body')} />
|
||||
@@ -219,7 +220,7 @@ export default function PackingTemplateManager() {
|
||||
{/* Add category */}
|
||||
{addingCategory ? (
|
||||
<div className={COMPOSER_ROW} style={{ boxShadow: COMPOSER.boxShadow }}>
|
||||
<input autoFocus value={newCatName} onChange={e => setNewCatName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={newCatName} onChange={e => setNewCatName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleAddCategory(); if (e.key === 'Escape') { setAddingCategory(false); setNewCatName('') } }}
|
||||
placeholder={t('admin.packingTemplates.categoryName')}
|
||||
className={COMPOSER_INPUT} style={fs(13, 'body')} />
|
||||
|
||||
@@ -67,7 +67,7 @@ function Catalog() {
|
||||
}}>
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('schoolCatalog.country')} htmlFor={`${fieldId}-name`}>
|
||||
<input id={`${fieldId}-name`} autoFocus required maxLength={100} className={INPUT} value={name} onChange={event => setName(event.target.value)} />
|
||||
<input id={`${fieldId}-name`} data-initial-focus required maxLength={100} className={INPUT} value={name} onChange={event => setName(event.target.value)} />
|
||||
</EditorField>
|
||||
<EditorField label={t('schoolCatalog.code')} htmlFor={`${fieldId}-code`}>
|
||||
<input id={`${fieldId}-code`} required pattern="[A-Z]{2}" maxLength={2} className={`${INPUT} font-geist uppercase tracking-[.08em]`} value={code} onChange={event => setCode(event.target.value.toUpperCase())} placeholder="US" />
|
||||
|
||||
@@ -62,7 +62,7 @@ export default function SchoolHolidayRegionEditor({ region, busy, offline = fals
|
||||
<div className={BODY}>
|
||||
<fieldset disabled={busy || offline} className={`m-0 flex min-w-0 flex-col gap-5 border-0 p-0 ${busy ? 'opacity-60' : ''}`}>
|
||||
<EditorField label={t('schoolCatalog.region')} htmlFor={`${fieldId}-region`}>
|
||||
<input id={`${fieldId}-region`} autoFocus required maxLength={150} className={INPUT} value={name} onChange={event => setName(event.target.value)} />
|
||||
<input id={`${fieldId}-region`} data-initial-focus required maxLength={150} className={INPUT} value={name} onChange={event => setName(event.target.value)} />
|
||||
</EditorField>
|
||||
<SettingsHint>{t('schoolCatalog.periodHint')}</SettingsHint>
|
||||
{holidays.map((holiday, index) => {
|
||||
|
||||
@@ -17,6 +17,10 @@ const h = vi.hoisted(() => {
|
||||
insets: number[] = [];
|
||||
kicks = 0;
|
||||
disposed = false;
|
||||
static create(opts: GlobeEngineOptions): FakeEngine {
|
||||
return new FakeEngine(opts);
|
||||
}
|
||||
|
||||
constructor(opts: GlobeEngineOptions) {
|
||||
if (state.failNext !== null) {
|
||||
const err = state.failNext;
|
||||
|
||||
@@ -54,7 +54,7 @@ const AtlasGlobe = forwardRef<AtlasGlobeHandle, AtlasGlobeProps>(function AtlasG
|
||||
if (!canvas) return;
|
||||
let engine: GlobeEngine;
|
||||
try {
|
||||
engine = new GlobeEngine({
|
||||
engine = GlobeEngine.create({
|
||||
canvas,
|
||||
fetchJson: (p) => propsRef.current.fetchJson(p),
|
||||
theme: globeTheme(propsRef.current.dark),
|
||||
|
||||
@@ -210,7 +210,7 @@ async function start(o: StartOptions = {}) {
|
||||
onSelect: vi.fn(),
|
||||
onFrame: vi.fn(),
|
||||
};
|
||||
const engine = new mod.GlobeEngine({ canvas, fetchJson, theme: o.theme ?? LIGHT, initial: o.initial, ...cb });
|
||||
const engine = mod.GlobeEngine.create({ canvas, fetchJson, theme: o.theme ?? LIGHT, initial: o.initial, ...cb });
|
||||
engines.push(engine);
|
||||
return {
|
||||
mod,
|
||||
@@ -310,7 +310,7 @@ describe('GlobeEngine boot', () => {
|
||||
const otherFetch = vi.fn(async (): Promise<unknown> => null);
|
||||
const canvas = document.createElement('canvas');
|
||||
const onReady = vi.fn();
|
||||
const second = new first.mod.GlobeEngine({ canvas, fetchJson: otherFetch, theme: LIGHT, onReady });
|
||||
const second = first.mod.GlobeEngine.create({ canvas, fetchJson: otherFetch, theme: LIGHT, onReady });
|
||||
engines.push(second);
|
||||
await flush();
|
||||
expect(otherFetch).not.toHaveBeenCalled();
|
||||
@@ -345,7 +345,7 @@ describe('GlobeEngine boot retries', () => {
|
||||
});
|
||||
const onError = vi.fn();
|
||||
engines.push(
|
||||
new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson: fail, theme: LIGHT, onError })
|
||||
mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson: fail, theme: LIGHT, onError })
|
||||
);
|
||||
const delays: number[] = [];
|
||||
for (let i = 0; i < 4; i++) {
|
||||
@@ -364,7 +364,7 @@ describe('GlobeEngine boot retries', () => {
|
||||
const ok = vi.fn(async (p: string): Promise<unknown> => files[p]);
|
||||
const onReady = vi.fn();
|
||||
engines.push(
|
||||
new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson: ok, theme: LIGHT, onReady })
|
||||
mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson: ok, theme: LIGHT, onReady })
|
||||
);
|
||||
await flush();
|
||||
expect(ok).toHaveBeenCalledWith('manifest');
|
||||
@@ -381,7 +381,9 @@ describe('GlobeEngine boot retries', () => {
|
||||
return files[p];
|
||||
});
|
||||
const onReady = vi.fn();
|
||||
engines.push(new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson, theme: LIGHT, onReady }));
|
||||
engines.push(
|
||||
mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson, theme: LIGHT, onReady })
|
||||
);
|
||||
await flush();
|
||||
expect(pending.map((t) => t.ms)).toEqual([1000]);
|
||||
pending[0].cb();
|
||||
|
||||
@@ -164,7 +164,13 @@ export class GlobeEngine {
|
||||
private sun: [number, number, number] = sunVector(new Date());
|
||||
private sunAt = 0;
|
||||
|
||||
constructor(opts: GlobeEngineOptions) {
|
||||
static create(opts: GlobeEngineOptions): GlobeEngine {
|
||||
const engine = new GlobeEngine(opts);
|
||||
void engine.boot();
|
||||
return engine;
|
||||
}
|
||||
|
||||
private constructor(opts: GlobeEngineOptions) {
|
||||
this.opts = opts;
|
||||
this.theme = opts.theme;
|
||||
Object.assign(this.cam, opts.initial ?? {});
|
||||
@@ -187,7 +193,6 @@ export class GlobeEngine {
|
||||
this.resizeObs.observe(opts.canvas);
|
||||
opts.canvas.addEventListener('webglcontextlost', this.onContextLost);
|
||||
this.resize();
|
||||
void this.boot();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- loading
|
||||
|
||||
@@ -14,7 +14,7 @@ export function hexToRgb(hex: string): Rgb {
|
||||
.map((c) => c + c)
|
||||
.join('')
|
||||
: h.slice(0, 6);
|
||||
const n = parseInt(full, 16);
|
||||
const n = Number.parseInt(full, 16);
|
||||
if (Number.isNaN(n)) return [0.5, 0.5, 0.5];
|
||||
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'
|
||||
import { ChevronDown, Lock, Pencil, Plus, Trash2 } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
@@ -307,7 +308,7 @@ function TextInput({ value, onSave, onCancel, label, numeric = false }: {
|
||||
if (ev.key === 'Escape') { ev.preventDefault(); ev.stopPropagation(); finish(onCancel) }
|
||||
}
|
||||
return (
|
||||
<input autoFocus type="text" value={draft} aria-label={label} inputMode={numeric ? 'decimal' : undefined}
|
||||
<input ref={focusRevealedEditor} type="text" value={draft} aria-label={label} inputMode={numeric ? 'decimal' : undefined}
|
||||
onChange={ev => setDraft(ev.target.value)} onKeyDown={onKey} onBlur={() => finish(() => onSave(draft))}
|
||||
className={`${INPUT} ${numeric ? 'text-center tabular-nums' : ''}`} />
|
||||
)
|
||||
|
||||
@@ -197,7 +197,7 @@ function FilterMenu(f: CostsFilterProps & { splitting: boolean }) {
|
||||
</button>
|
||||
</Tooltip>
|
||||
{open && (
|
||||
<div role="menu" onKeyDown={e => { if (e.key === 'Escape') close() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width: 310 }}>
|
||||
<div role="menu" tabIndex={-1} onKeyDown={e => { if (e.key === 'Escape') close() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width: 310 }}>
|
||||
{f.splitting && <>
|
||||
<div className="mx-1.5 mb-1 mt-1.5 flex rounded-[10px] bg-surface-tertiary p-[3px]">
|
||||
{owners.map(([o, label]) => (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { cloneElement, CSSProperties, FormEvent, ReactElement, useEffect, useId, useRef, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { ExternalLink, Link2, Pencil, Pin, Plus, Trash2, X } from 'lucide-react'
|
||||
@@ -147,7 +148,7 @@ function LinkModal({ link, onClose, onSave }: { link?: CollabLink; onClose: () =
|
||||
<div style={{ padding: '14px 16px 16px', display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
<div>
|
||||
<label htmlFor="collab-link-title" style={{ ...label, display: 'block' }}>{t('collab.links.titlePlaceholder')}</label>
|
||||
<input id="collab-link-title" value={title} onChange={e => setTitle(e.target.value)} placeholder={t('collab.links.titlePlaceholder')} autoFocus style={field} />
|
||||
<input id="collab-link-title" value={title} onChange={e => setTitle(e.target.value)} placeholder={t('collab.links.titlePlaceholder')} ref={focusRevealedEditor} style={field} />
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="collab-link-url" style={{ ...label, display: 'block' }}>{t('collab.links.urlPlaceholder')}</label>
|
||||
|
||||
@@ -118,7 +118,7 @@ function CreatePollModal({ onClose, onCreate, t }: CreatePollModalProps) {
|
||||
)}
|
||||
>
|
||||
<EditorField label={t('collab.polls.question')} hint={t('collab.polls.markdownHint')}>
|
||||
<textarea autoFocus rows={4} value={question} onChange={e => setQuestion(e.target.value)} placeholder={t('collab.polls.questionPlaceholder')} className={`${TEXTAREA} resize-y`} />
|
||||
<textarea data-initial-focus rows={4} value={question} onChange={e => setQuestion(e.target.value)} placeholder={t('collab.polls.questionPlaceholder')} className={`${TEXTAREA} resize-y`} />
|
||||
</EditorField>
|
||||
|
||||
<EditorField label={t('collab.polls.options')}>
|
||||
|
||||
@@ -102,7 +102,6 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
|
||||
<div className="relative">
|
||||
<Search size={14} className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint" aria-hidden="true" />
|
||||
<input
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
ref={searchRef}
|
||||
type="text"
|
||||
|
||||
@@ -136,6 +136,7 @@ export default function CollectionExportMenu({ onExport, exporting, t }: Collect
|
||||
ref={menuRef}
|
||||
id={menuId}
|
||||
role="menu"
|
||||
tabIndex={-1}
|
||||
aria-label={t('collections.file.exportTitle')}
|
||||
onKeyDown={onMenuKeyDown}
|
||||
className="trek-popover-enter fixed z-[var(--z-toast)] p-1.5 rounded-xl border border-edge bg-surface-card shadow-dropdown"
|
||||
|
||||
@@ -25,6 +25,7 @@ import { placesPath } from '../../utils/placesRoutes';
|
||||
import MarkdownToolbar from '../Journey/MarkdownToolbar';
|
||||
import { getNavigationTargets, navigationTargetLabel, openNavigationTarget } from '../Planner/placeNavigation';
|
||||
import { getCategoryIcon } from '../shared/categoryIcons';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import { DialogShell } from '../shared/DialogShell';
|
||||
import { markdownLinkComponents } from '../shared/markdownLink';
|
||||
import { NavigationMenu } from '../shared/NavigationMenu';
|
||||
@@ -202,7 +203,7 @@ function Cover({
|
||||
value={form.name}
|
||||
onChange={(e) => form.setName(e.target.value)}
|
||||
className="col-detail-name-input min-w-0 flex-1"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
aria-label={t('common.name')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -55,7 +55,7 @@ export default function CopyToTripModal({ isOpen, onClose, placeIds, onCopy, car
|
||||
<div className="relative">
|
||||
<Search size={14} className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint" aria-hidden="true" />
|
||||
<input
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder={t('collections.copyToTripSearch')}
|
||||
|
||||
@@ -67,7 +67,7 @@ export default function MoveToListModal({ mode, lists, count, onPick, onClose, t
|
||||
<div className="relative">
|
||||
<Search size={14} className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint" aria-hidden="true" />
|
||||
<input
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder={t('collections.searchLists')}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import type { PlacesLibraryDetailResponse } from '@trek/shared';
|
||||
import { Bookmark, Eye, Layers, Luggage, NotebookPen, Pencil, PenLine } from 'lucide-react';
|
||||
import React, { useRef } from 'react';
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
import Markdown from 'react-markdown';
|
||||
import remarkBreaks from 'remark-breaks';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import type { TranslationFn } from '../../types';
|
||||
import MarkdownToolbar from '../Journey/MarkdownToolbar';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import { markdownLinkComponents } from '../shared/markdownLink';
|
||||
import { Tooltip } from '../shared/Tooltip';
|
||||
import PlaceCard from './PlaceCard';
|
||||
@@ -51,6 +52,10 @@ function NoteCard({ note, n, t }: { note: OriginNote; n: Notes; t: TranslationFn
|
||||
*/
|
||||
function NoteEditor({ n, t }: { n: Notes; t: TranslationFn }) {
|
||||
const ref = useRef<HTMLTextAreaElement>(null);
|
||||
const attachEditor = useCallback((element: HTMLTextAreaElement | null) => {
|
||||
ref.current = element;
|
||||
focusRevealedEditor(element);
|
||||
}, []);
|
||||
const current = n.composeTargets.find((x) => x.key === n.editing) ?? n.notes.find((x) => x.key === n.editing);
|
||||
const multi = n.isNew && n.composeTargets.length > 1;
|
||||
return (
|
||||
@@ -111,8 +116,7 @@ function NoteEditor({ n, t }: { n: Notes; t: TranslationFn }) {
|
||||
</div>
|
||||
) : (
|
||||
<textarea
|
||||
ref={ref}
|
||||
autoFocus
|
||||
ref={attachEditor}
|
||||
rows={6}
|
||||
value={n.draft}
|
||||
onChange={(e) => n.setDraft(e.target.value)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { MapPin } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import type { Category, TranslationFn } from '../../types';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import { NumericInput } from '../shared/NumericInput';
|
||||
import CategoryTileMenu from './CategoryTileMenu';
|
||||
import type { PlaceEditState } from './usePlaceEdit';
|
||||
@@ -36,7 +37,7 @@ export default function PlaceEditForm({
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={draft.name}
|
||||
onChange={(e) => edit.set('name', e.target.value)}
|
||||
aria-label={t('common.name')}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Bookmark, Check, Luggage, Plus, Search, Tag, X } from 'lucide-react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import type { TranslationFn } from '../../types';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import PlaceCard from './PlaceCard';
|
||||
import type { PlaceTagsState, TagGroup } from './usePlaceTags';
|
||||
|
||||
@@ -38,7 +39,7 @@ function TagPicker({ tags, group, t }: { tags: PlaceTagsState; group: TagGroup;
|
||||
>
|
||||
<Search size={14} aria-hidden="true" />
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={tags.query}
|
||||
onChange={(e) => tags.setQuery(e.target.value)}
|
||||
placeholder={t('placeTags.search')}
|
||||
|
||||
@@ -55,7 +55,7 @@ export default function SaveTripPlacesToListModal({ isOpen, tripId, placeIds, on
|
||||
<div className="relative">
|
||||
<Search size={14} className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint" aria-hidden="true" />
|
||||
<input
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder={t('collections.searchLists')}
|
||||
|
||||
@@ -8,7 +8,9 @@ import { getApiErrorMessage } from '../../utils/apiError';
|
||||
import { useToast } from '../shared/Toast';
|
||||
|
||||
/** A pair's own name: its two keys in a fixed order, so either way round it is one pair. */
|
||||
export const pairKey = (d: Pick<PlacesLibraryDuplicate, 'a' | 'b'>): string => [d.a.key, d.b.key].sort().join('|');
|
||||
export function pairKey({ a, b }: Pick<PlacesLibraryDuplicate, 'a' | 'b'>): string {
|
||||
return a.key <= b.key ? `${a.key}|${b.key}` : `${b.key}|${a.key}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places that look like the same place (PLC-13), behind the desktop dialog and the
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ArrowLeft, ArrowRight, Clock, ExternalLink, Images, RotateCcw } from 'lucide-react';
|
||||
import { lazy, Suspense, useId } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import {
|
||||
DialogButton,
|
||||
DialogFooter,
|
||||
@@ -116,7 +117,7 @@ function FooterLinks({ t, onCredits, focusCredits }: { t: Translate; onCredits:
|
||||
<button
|
||||
type="button"
|
||||
onClick={onCredits}
|
||||
autoFocus={focusCredits}
|
||||
ref={focusCredits ? focusRevealedEditor : undefined}
|
||||
className={FOOTER_LINK}
|
||||
style={fs(12.5, 'body')}
|
||||
>
|
||||
|
||||
@@ -106,17 +106,17 @@ export default function DocSyncConnectModal({
|
||||
</Field>
|
||||
))}
|
||||
|
||||
<label className="flex items-start justify-between gap-4 rounded-lg border border-edge bg-surface-secondary px-3 py-2.5">
|
||||
<div className="flex items-start justify-between gap-4 rounded-lg border border-edge bg-surface-secondary px-3 py-2.5">
|
||||
<span className="min-w-0">
|
||||
<span className="block text-body text-content">{t('docsync.allowInsecureTls')}</span>
|
||||
<span className="mt-0.5 block text-caption text-content-muted">
|
||||
<span id={`${labelId}-tls-hint`} className="mt-0.5 block text-caption text-content-muted">
|
||||
{t('docsync.connect.insecureHint')}
|
||||
</span>
|
||||
</span>
|
||||
<span className="shrink-0 pt-0.5">
|
||||
<ToggleSwitch on={form.insecureTls} onToggle={() => form.setInsecureTls(!form.insecureTls)} />
|
||||
<ToggleSwitch on={form.insecureTls} onToggle={() => form.setInsecureTls(!form.insecureTls)} label={t('docsync.allowInsecureTls')} describedBy={`${labelId}-tls-hint`} />
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
|
||||
@@ -206,7 +206,7 @@ export default function ContributorInviteDialog({ journeyId, existingUserIds, on
|
||||
<div className="relative">
|
||||
<Search size={14} className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint" aria-hidden="true" />
|
||||
<input
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder={t('journey.contributors.searchPlaceholder')}
|
||||
|
||||
@@ -51,7 +51,7 @@ export function AddTripDialog({ journeyId, existingTripIds, onClose, onAdded }:
|
||||
<div className="relative">
|
||||
<Search size={14} className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint" aria-hidden="true" />
|
||||
<input
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder={t('journey.trips.searchPlaceholder')}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
stripTrailingSlashes,
|
||||
resolveValhallaProvider,
|
||||
VALHALLA_COSTING,
|
||||
VALHALLA_RELAY_MAX_LOCATIONS,
|
||||
@@ -245,7 +246,7 @@ export function valhallaBase(): string | null {
|
||||
*/
|
||||
function currentProvider(ignoreRest = false): { provider: ValhallaProvider | null; own: string } {
|
||||
const settings = useSettingsStore.getState().settings
|
||||
const own = settings.valhalla_base_url?.trim().replace(/\/+$/, '') ?? ''
|
||||
const own = stripTrailingSlashes(settings.valhalla_base_url?.trim() ?? '')
|
||||
const provider = resolveValhallaProvider({
|
||||
provider: settings.routing_valhalla_provider,
|
||||
valhallaUrl: own,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { useState, useRef, useCallback } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { X, Plus } from 'lucide-react'
|
||||
@@ -37,7 +38,7 @@ export function BagCard({ bag, bagItems, totalWeight, pct, tripId, tripMembers,
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: sz.gap }}>
|
||||
<span style={{ width: sz.dot, height: sz.dot, borderRadius: '50%', background: bag.color, flexShrink: 0 }} />
|
||||
{editingName && canEdit ? (
|
||||
<input autoFocus value={nameVal} onChange={e => setNameVal(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={nameVal} onChange={e => setNameVal(e.target.value)}
|
||||
onBlur={saveName} onKeyDown={e => { if (e.key === 'Enter') saveName(); if (e.key === 'Escape') cancelName() }}
|
||||
style={{ flex: 1, fontSize: sz.name, fontWeight: 600, padding: '1px 4px', borderRadius: 4, border: '1px solid var(--border-primary)', outline: 'none', fontFamily: 'inherit', color: 'var(--text-primary)', background: 'transparent' }} />
|
||||
) : (
|
||||
@@ -101,7 +102,7 @@ export function BagCard({ bag, bagItems, totalWeight, pct, tripId, tripMembers,
|
||||
{editingLimit && canEdit ? (
|
||||
<>
|
||||
<span>/</span>
|
||||
<input autoFocus value={limitVal} onChange={e => setLimitVal(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={limitVal} onChange={e => setLimitVal(e.target.value)}
|
||||
onBlur={saveLimit}
|
||||
onKeyDown={e => { if (e.key === 'Enter') saveLimit(); if (e.key === 'Escape') cancelLimit() }}
|
||||
inputMode="decimal" aria-label={t('packing.bagLimit')} placeholder={t('packing.bagLimit')}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { X, Plus } from 'lucide-react'
|
||||
import type { PackingState } from './usePackingListPanel'
|
||||
import { bagFillPct, bagLoadSummary, packedWeight, perPersonLoads } from './packingListPanel.helpers'
|
||||
@@ -72,7 +73,7 @@ export function BagModal(S: PackingState) {
|
||||
{/* Add bag */}
|
||||
{canEdit && (showAddBag ? (
|
||||
<div style={{ display: 'flex', gap: 6, marginTop: 14 }}>
|
||||
<input autoFocus value={newBagName} onChange={e => setNewBagName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={newBagName} onChange={e => setNewBagName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleCreateBag(); if (e.key === 'Escape') { setShowAddBag(false); setNewBagName('') } }}
|
||||
placeholder={t('packing.bagName')}
|
||||
style={{ flex: 1, padding: '8px 12px', borderRadius: 10, border: '1px solid var(--border-primary)', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontFamily: 'inherit', outline: 'none' }} />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { useCallback, useRef } from 'react'
|
||||
import { Briefcase, Plus, X } from 'lucide-react'
|
||||
import type { PackingState } from './usePackingListPanel'
|
||||
@@ -47,7 +48,7 @@ export function BagSidebar(S: PackingState) {
|
||||
{canEdit && showAddBag && (
|
||||
<div ref={composerRef} style={{ ...COMPOSER, margin: '10px 10px 0', paddingBlock: 4, paddingInlineEnd: 4, paddingInlineStart: 10 }}>
|
||||
<span aria-hidden style={{ width: 10, height: 10, borderRadius: '50%', border: '1.5px dashed var(--text-faint)', flexShrink: 0 }} />
|
||||
<input autoFocus value={newBagName} onChange={e => setNewBagName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={newBagName} onChange={e => setNewBagName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleCreateBag(); if (e.key === 'Escape') closeComposer() }}
|
||||
placeholder={t('packing.bagName')}
|
||||
style={{ flex: 1, minWidth: 0, padding: '5px 0', border: 'none', fontSize: 'calc(12.5px * var(--fs-scale-body, 1))', fontWeight: 500, fontFamily: 'inherit', outline: 'none', color: 'var(--text-primary)', background: 'transparent' }} />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import React, { useState, useRef, useEffect } from 'react'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
import { useToast } from '../shared/Toast'
|
||||
@@ -140,7 +141,7 @@ export function KategorieGruppe({ kategorie, items, tripId, allCategories, onRen
|
||||
|
||||
{editingName && canEdit ? (
|
||||
<input
|
||||
autoFocus value={editKatName}
|
||||
ref={focusRevealedEditor} value={editKatName}
|
||||
onChange={e => setEditKatName(e.target.value)}
|
||||
onBlur={handleSaveKatName}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleSaveKatName(); if (e.key === 'Escape') { setEditingName(false); setEditKatName(kategorie) } }}
|
||||
@@ -319,7 +320,6 @@ export function KategorieGruppe({ kategorie, items, tripId, allCategories, onRen
|
||||
<span aria-hidden style={{ width: 20, height: 20, borderRadius: 6, border: '1.5px solid var(--text-faint)', flexShrink: 0 }} />
|
||||
<input
|
||||
ref={addItemRef}
|
||||
autoFocus
|
||||
value={newItemName}
|
||||
onChange={e => setNewItemName(e.target.value)}
|
||||
onKeyDown={e => {
|
||||
@@ -404,8 +404,7 @@ function CategoryGrip({ drag, kategorie, label }: { drag?: CategoryDrag; kategor
|
||||
return (
|
||||
<span
|
||||
draggable
|
||||
role="button"
|
||||
aria-label={label}
|
||||
aria-hidden="true"
|
||||
title={label}
|
||||
onDragStart={e => {
|
||||
e.dataTransfer.effectAllowed = 'move'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { replaceInlineMarkdownLinks } from '@trek/shared'
|
||||
import type { PackingBag, PackingItem } from '../../types'
|
||||
import { KAT_COLORS, PACKING_PLACEHOLDER_NAME } from './packingListPanel.constants'
|
||||
|
||||
@@ -7,7 +8,7 @@ export function katColor(kat: string, allCategories?: string[]): string {
|
||||
if (idx >= 0) return KAT_COLORS[idx % KAT_COLORS.length]
|
||||
// Fallback: hash-based
|
||||
let h = 0
|
||||
for (let i = 0; i < kat.length; i++) h = ((h << 5) - h + (kat.codePointAt(i) ?? 0)) | 0
|
||||
for (let i = 0; i < kat.length; i++) h = Math.imul((h << 5) - h + (kat.codePointAt(i) ?? 0), 1)
|
||||
return KAT_COLORS[Math.abs(h) % KAT_COLORS.length]
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@ const MD_WEIGHT = /\((\d+(?:[.,]\d+)?)\s?(g|kg)\)$/i
|
||||
|
||||
/** Links, emphasis and code marks as plain text: a list copied from a notes app is full of them. */
|
||||
const plainMarkdown = (text: string): string =>
|
||||
text.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/\*\*|__|~~|`/g, '').trim()
|
||||
replaceInlineMarkdownLinks(text, (label) => label, true).replace(/\*\*|__|~~|`/g, '').trim()
|
||||
|
||||
/**
|
||||
* Whether pasted text is a Markdown list rather than CSV rows (#875): any heading or
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { useState } from 'react'
|
||||
import { Plus, X, MapPin } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
@@ -40,7 +41,7 @@ export function MobileAddPlaceButton({ dayId, places, assignments, onAssign, onA
|
||||
<div style={{ borderRadius: 14, border: '1px solid var(--border-primary)', background: 'var(--bg-card)', overflow: 'hidden' }}>
|
||||
<div style={{ padding: '8px 10px', borderBottom: '1px solid var(--border-faint)', display: 'flex', gap: 6 }}>
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder={t('dayplan.mobile.searchPlaces')}
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { Category, Place } from '../../types';
|
||||
import { safeHexColor } from '../../utils/safeColor';
|
||||
import type { StopKind } from '../Roadtrip/stopKinds';
|
||||
import { getCategoryIcon } from '../shared/categoryIcons';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import { PillSelect } from '../shared/dialogParts';
|
||||
import { PILL } from '../shared/DialogShell';
|
||||
import { NavigationMenu } from '../shared/NavigationMenu';
|
||||
@@ -185,7 +186,7 @@ function NewCategoryField({ inputId, name, setName, create, setOpen, t }: NewCat
|
||||
<input
|
||||
id={inputId}
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
|
||||
@@ -644,7 +644,7 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
|
||||
type="text"
|
||||
// A new place starts at the search; an edit or a place brought
|
||||
// in from the map already has what the search would give.
|
||||
autoFocus={!place && !prefillCoords}
|
||||
data-initial-focus={(!place && !prefillCoords) || undefined}
|
||||
value={mapsSearch}
|
||||
onChange={e => { setMapsSearch(e.target.value); S.setEmptySearch(null) }}
|
||||
onKeyDown={handleSearchKeyDown}
|
||||
|
||||
@@ -81,7 +81,7 @@ export function ListImportModal(S: SidebarState) {
|
||||
onChange={e => setListImportUrl(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter' && !listImportLoading) void handleListImport() }}
|
||||
placeholder={google ? 'https://maps.app.goo.gl/...' : 'https://naver.me/...'}
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
className={INPUT}
|
||||
/>
|
||||
</EditorField>
|
||||
|
||||
@@ -848,7 +848,7 @@ describe('ReservationsPanel', () => {
|
||||
const user = userEvent.setup();
|
||||
const onEdit = vi.fn();
|
||||
render(<ReservationsPanel {...defaultProps} reservations={[transitJourney()]} onEdit={onEdit} />);
|
||||
await user.click(screen.getByRole('article', { name: /Hamburg Hbf/ }));
|
||||
await user.click(screen.getByRole('button', { name: /Hamburg Hbf/ }));
|
||||
const detail = await screen.findByRole('dialog');
|
||||
expect(onEdit).not.toHaveBeenCalled();
|
||||
await user.click(within(detail).getByRole('button', { name: 'Edit' }));
|
||||
|
||||
@@ -274,11 +274,11 @@ describe('ReservationsPanel views', () => {
|
||||
it('FE-PLANNER-RESVIEW-016: a card opens the detail on click or Enter, and Close shuts it', async () => {
|
||||
const user = userEvent.setup();
|
||||
renderPanel();
|
||||
await user.click(screen.getByRole('article', { name: 'LH 716' }));
|
||||
await user.click(within(screen.getByRole('article', { name: 'LH 716' })).getByRole('button', { name: 'LH 716' }));
|
||||
expect(screen.getByRole('dialog', { name: 'LH 716' })).toBeInTheDocument();
|
||||
await user.click(within(screen.getByRole('dialog', { name: 'LH 716' })).getByRole('button', { name: 'Close' }));
|
||||
expect(screen.queryByRole('dialog', { name: 'LH 716' })).toBeNull();
|
||||
screen.getByRole('article', { name: 'LH 716' }).focus();
|
||||
within(screen.getByRole('article', { name: 'LH 716' })).getByRole('button', { name: 'LH 716' }).focus();
|
||||
await user.keyboard('{Enter}');
|
||||
expect(screen.getByRole('dialog', { name: 'LH 716' })).toBeInTheDocument();
|
||||
});
|
||||
@@ -286,7 +286,7 @@ describe('ReservationsPanel views', () => {
|
||||
it('FE-PLANNER-RESVIEW-017: deleting the booking the detail shows closes the detail first', async () => {
|
||||
const user = userEvent.setup();
|
||||
renderPanel();
|
||||
await user.click(screen.getByRole('article', { name: 'Kaiseki dinner' }));
|
||||
await user.click(within(screen.getByRole('article', { name: 'Kaiseki dinner' })).getByRole('button', { name: 'Kaiseki dinner' }));
|
||||
expect(screen.getByRole('dialog', { name: 'Kaiseki dinner' })).toBeInTheDocument();
|
||||
await user.click(within(screen.getByRole('article', { name: 'Kaiseki dinner' })).getByRole('button', { name: 'Delete' }));
|
||||
const deletes = screen.getAllByRole('button', { name: 'Delete' });
|
||||
|
||||
@@ -49,112 +49,112 @@ export default function BookingCard(p: BookingCardProps) {
|
||||
const { t, locale } = useTranslation()
|
||||
const tone = toneOf(r)
|
||||
const transit = r.type === 'transit'
|
||||
const title = displayTitle(r)
|
||||
|
||||
return (
|
||||
<article
|
||||
tabIndex={0}
|
||||
onClick={p.onSelect}
|
||||
onKeyDown={e => { if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); p.onSelect() } }}
|
||||
aria-label={displayTitle(r)}
|
||||
className={`group flex cursor-pointer flex-col overflow-hidden rounded-2xl border bg-surface-secondary transition-shadow hover:shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-[color:var(--text-primary)] ${p.selected ? 'border-[color:var(--text-primary)]' : 'border-edge-faint'}`}
|
||||
aria-label={title}
|
||||
className={`group flex cursor-pointer flex-col overflow-hidden rounded-2xl border bg-surface-secondary transition-shadow hover:shadow-md ${p.selected ? 'border-[color:var(--text-primary)]' : 'border-edge-faint'}`}
|
||||
>
|
||||
<div className="flex items-center gap-2 border-b border-edge-faint px-3 py-2.5" style={{ background: toneTint(tone) }}>
|
||||
<StatusDot r={r} canToggle={p.canEdit} onToggle={p.onToggleStatus} />
|
||||
<TypeChip type={r.type} />
|
||||
<span className="flex min-w-0 flex-1 items-center gap-1.5">
|
||||
<span className="min-w-0 truncate font-bold text-content" style={fs(13.5, 'body')}>{displayTitle(r)}</span>
|
||||
{!!r.needs_review && <ReviewPill />}
|
||||
</span>
|
||||
<AirTrailPill r={r} />
|
||||
{p.canEdit && <RoundAction label={t('common.edit')} onClick={p.onEdit}><Pencil size={12} strokeWidth={2} /></RoundAction>}
|
||||
{p.canEdit && <RoundAction label={t('common.delete')} onClick={p.onDelete} danger><Trash2 size={12} strokeWidth={2} /></RoundAction>}
|
||||
</div>
|
||||
<div role="presentation" onClick={p.onSelect} className="flex flex-1 flex-col">
|
||||
<div className="flex items-center gap-2 border-b border-edge-faint px-3 py-2.5" style={{ background: toneTint(tone) }}>
|
||||
<StatusDot r={r} canToggle={p.canEdit} onToggle={p.onToggleStatus} />
|
||||
<TypeChip type={r.type} />
|
||||
<button type="button" aria-label={title} className="flex min-w-0 flex-1 items-center gap-1.5 rounded text-start focus-visible:outline focus-visible:outline-2 focus-visible:outline-[color:var(--text-primary)]">
|
||||
<span className="min-w-0 truncate font-bold text-content" style={fs(13.5, 'body')}>{title}</span>
|
||||
{!!r.needs_review && <ReviewPill />}
|
||||
</button>
|
||||
<AirTrailPill r={r} />
|
||||
{p.canEdit && <RoundAction label={t('common.edit')} onClick={p.onEdit}><Pencil size={12} strokeWidth={2} /></RoundAction>}
|
||||
{p.canEdit && <RoundAction label={t('common.delete')} onClick={p.onDelete} danger><Trash2 size={12} strokeWidth={2} /></RoundAction>}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-1 flex-col gap-2 px-3 pb-3 pt-2.5">
|
||||
<WhenFields facts={facts} />
|
||||
<FlightLiveStrip tripId={p.tripId} reservationId={r.id} type={r.type} />
|
||||
<div className="flex flex-1 flex-col gap-2 px-3 pb-3 pt-2.5">
|
||||
<WhenFields facts={facts} />
|
||||
<FlightLiveStrip tripId={p.tripId} reservationId={r.id} type={r.type} />
|
||||
|
||||
{transit ? <TransitBody r={r} /> : (
|
||||
<>
|
||||
{r.confirmation_number && (
|
||||
<Field label={t('reservations.confirmationCode')} tabular>
|
||||
<BlurredCode className="font-geist">{r.confirmation_number}</BlurredCode>
|
||||
</Field>
|
||||
)}
|
||||
<RouteBox type={r.type} facts={facts} />
|
||||
{facts.legCodes.length > 0 && (
|
||||
<Block label={t('reservations.segmentCodes')}>
|
||||
<div className={`${BOX} flex flex-col gap-1 px-[10px] py-2`}>
|
||||
{facts.legCodes.map((l, i) => (
|
||||
<div key={i} className="flex items-center gap-2" style={fs(12, 'body')}>
|
||||
<span className="min-w-0 flex-1 truncate font-medium text-content-secondary">{l.route || t('reservations.confirmationCode')}</span>
|
||||
<BlurredCode className="font-geist tabular-nums text-content-muted">{l.code}</BlurredCode>
|
||||
</div>
|
||||
))}
|
||||
{transit ? <TransitBody r={r} /> : (
|
||||
<>
|
||||
{r.confirmation_number && (
|
||||
<Field label={t('reservations.confirmationCode')} tabular>
|
||||
<BlurredCode className="font-geist">{r.confirmation_number}</BlurredCode>
|
||||
</Field>
|
||||
)}
|
||||
<RouteBox type={r.type} facts={facts} />
|
||||
{facts.legCodes.length > 0 && (
|
||||
<Block label={t('reservations.segmentCodes')}>
|
||||
<div className={`${BOX} flex flex-col gap-1 px-[10px] py-2`}>
|
||||
{facts.legCodes.map((l, i) => (
|
||||
<div key={i} className="flex items-center gap-2" style={fs(12, 'body')}>
|
||||
<span className="min-w-0 flex-1 truncate font-medium text-content-secondary">{l.route || t('reservations.confirmationCode')}</span>
|
||||
<BlurredCode className="font-geist tabular-nums text-content-muted">{l.code}</BlurredCode>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Block>
|
||||
)}
|
||||
{facts.cells.length > 0 && (
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{facts.cells.map((c, i) => <Field key={i} label={c.label}>{c.value}</Field>)}
|
||||
</div>
|
||||
</Block>
|
||||
)}
|
||||
{facts.cells.length > 0 && (
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{facts.cells.map((c, i) => <Field key={i} label={c.label}>{c.value}</Field>)}
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{facts.place && <Field label={t('reservations.locationAddress')}>{facts.place}</Field>}
|
||||
{facts.accommodation && <Field label={t('reservations.meta.linkAccommodation')}>{facts.accommodation}</Field>}
|
||||
{facts.linked && <Field label={t('reservations.linkedTo')}>{facts.linked}</Field>}
|
||||
{facts.url && (
|
||||
<Field label={t('reservations.urlLabel')}>
|
||||
{facts.url.href
|
||||
? <a href={facts.url.href} target="_blank" rel="noopener noreferrer" onClick={e => e.stopPropagation()} className="text-content hover:underline">{facts.url.href}</a>
|
||||
: facts.url.text}
|
||||
</Field>
|
||||
)}
|
||||
|
||||
{r.notes && (
|
||||
<Block label={t('reservations.notes')}>
|
||||
<div className={`${BOX} collab-note-md line-clamp-4 px-[10px] py-2 text-content-muted`} style={fs(12, 'body')}>
|
||||
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} components={markdownLinkComponents}>{r.notes}</Markdown>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Block>
|
||||
)}
|
||||
|
||||
{facts.place && <Field label={t('reservations.locationAddress')}>{facts.place}</Field>}
|
||||
{facts.accommodation && <Field label={t('reservations.meta.linkAccommodation')}>{facts.accommodation}</Field>}
|
||||
{facts.linked && <Field label={t('reservations.linkedTo')}>{facts.linked}</Field>}
|
||||
{facts.url && (
|
||||
<Field label={t('reservations.urlLabel')}>
|
||||
{facts.url.href
|
||||
? <a href={facts.url.href} target="_blank" rel="noopener noreferrer" onClick={e => e.stopPropagation()} className="text-content hover:underline">{facts.url.href}</a>
|
||||
: facts.url.text}
|
||||
</Field>
|
||||
)}
|
||||
{(r.travelers || []).length > 0 && (
|
||||
<Block label={t('reservations.travelers.label')}>
|
||||
<TravelerChips travelers={r.travelers || []} />
|
||||
</Block>
|
||||
)}
|
||||
|
||||
{r.notes && (
|
||||
<Block label={t('reservations.notes')}>
|
||||
<div className={`${BOX} collab-note-md line-clamp-4 px-[10px] py-2 text-content-muted`} style={fs(12, 'body')}>
|
||||
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} components={markdownLinkComponents}>{r.notes}</Markdown>
|
||||
{p.files.length > 0 && (
|
||||
<Block label={t('files.title')}>
|
||||
<FileRows files={p.files} />
|
||||
</Block>
|
||||
)}
|
||||
|
||||
{p.costs.length > 0 && (
|
||||
<div className="mt-auto flex flex-wrap justify-end gap-1.5 pt-0.5">
|
||||
{p.costs.map(c => (
|
||||
<span key={c.currency} className="inline-flex items-center gap-1 rounded-full bg-surface-tertiary px-2.5 py-[3px] font-geist font-semibold tabular-nums text-content-secondary" style={fs(11.5)}>
|
||||
<Wallet size={11} strokeWidth={2} className="text-content-faint" />
|
||||
{formatMoney(c.amount, c.currency, locale)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</Block>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
|
||||
{(r.travelers || []).length > 0 && (
|
||||
<Block label={t('reservations.travelers.label')}>
|
||||
<TravelerChips travelers={r.travelers || []} />
|
||||
</Block>
|
||||
)}
|
||||
|
||||
{p.files.length > 0 && (
|
||||
<Block label={t('files.title')}>
|
||||
<FileRows files={p.files} />
|
||||
</Block>
|
||||
)}
|
||||
|
||||
{p.costs.length > 0 && (
|
||||
<div className="mt-auto flex flex-wrap justify-end gap-1.5 pt-0.5">
|
||||
{p.costs.map(c => (
|
||||
<span key={c.currency} className="inline-flex items-center gap-1 rounded-full bg-surface-tertiary px-2.5 py-[3px] font-geist font-semibold tabular-nums text-content-secondary" style={fs(11.5)}>
|
||||
<Wallet size={11} strokeWidth={2} className="text-content-faint" />
|
||||
{formatMoney(c.amount, c.currency, locale)}
|
||||
</span>
|
||||
<PluginCardFooter items={p.contributions} tripId={p.tripId} />
|
||||
{p.showFrames && p.detailPlugins.length > 0 && (
|
||||
<div role="presentation" onClick={e => e.stopPropagation()} className="flex flex-col gap-2 px-3 pb-3">
|
||||
{p.detailPlugins.map(pl => (
|
||||
<div key={pl.id} className={`${BOX} overflow-hidden`}>
|
||||
<PluginFrame pluginId={pl.id} tripId={String(p.tripId)} reservationId={String(r.id)} title={pl.name} surface="detail-slot" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<PluginCardFooter items={p.contributions} tripId={p.tripId} />
|
||||
{p.showFrames && p.detailPlugins.length > 0 && (
|
||||
<div role="presentation" onClick={e => e.stopPropagation()} className="flex flex-col gap-2 px-3 pb-3">
|
||||
{p.detailPlugins.map(pl => (
|
||||
<div key={pl.id} className={`${BOX} overflow-hidden`}>
|
||||
<PluginFrame pluginId={pl.id} tripId={String(p.tripId)} reservationId={String(r.id)} title={pl.name} surface="detail-slot" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ function usePopover() {
|
||||
|
||||
function Menu({ children, onClose, width = 260 }: { children: ReactNode; onClose: () => void; width?: number }) {
|
||||
return (
|
||||
<div role="menu" onKeyDown={e => { if (e.key === 'Escape') onClose() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width }}>
|
||||
<div role="menu" tabIndex={-1} onKeyDown={e => { if (e.key === 'Escape') onClose() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width }}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ export default function BookingsList(p: BookingsListProps) {
|
||||
const rootRef = useRef<HTMLDivElement>(null)
|
||||
const flat = p.groups.flatMap(g => (p.collapsed(g.id) ? [] : g.items))
|
||||
|
||||
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
||||
const onNavigate = (e: KeyboardEvent<HTMLElement>) => {
|
||||
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return
|
||||
e.preventDefault()
|
||||
const focused = document.activeElement instanceof HTMLElement ? Number(document.activeElement.dataset.row) : Number.NaN
|
||||
@@ -45,13 +45,13 @@ export default function BookingsList(p: BookingsListProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={rootRef} onKeyDown={onKeyDown} className="flex flex-col gap-6">
|
||||
<div ref={rootRef} className="flex flex-col gap-6">
|
||||
{p.groups.map(g => {
|
||||
const open = !p.collapsed(g.id)
|
||||
return (
|
||||
<section key={g.id} className="overflow-hidden rounded-2xl border border-edge-faint bg-surface-card">
|
||||
{g.label && (
|
||||
<button type="button" onClick={() => p.onToggleGroup(g.id)} aria-expanded={open}
|
||||
<button type="button" onClick={() => p.onToggleGroup(g.id)} onKeyDown={onNavigate} aria-expanded={open}
|
||||
className="flex w-full items-center gap-2 bg-surface-secondary px-3.5 py-2.5 text-start">
|
||||
<span className={EYEBROW} style={fs(10.5)}>{g.label}</span>
|
||||
{g.sub && <span className="truncate font-geist font-medium text-content-muted" style={fs(11.5)}>{g.sub}</span>}
|
||||
@@ -59,7 +59,7 @@ export default function BookingsList(p: BookingsListProps) {
|
||||
</button>
|
||||
)}
|
||||
{open && g.items.map(r => (
|
||||
<Row key={r.id} r={r} p={p} facts={p.factsOf(r)} files={p.filesCount(r)} costs={p.costsOf(r)} t={t} locale={locale} />
|
||||
<Row key={r.id} r={r} p={p} facts={p.factsOf(r)} files={p.filesCount(r)} costs={p.costsOf(r)} t={t} locale={locale} onNavigate={onNavigate} />
|
||||
))}
|
||||
</section>
|
||||
)
|
||||
@@ -68,7 +68,7 @@ export default function BookingsList(p: BookingsListProps) {
|
||||
)
|
||||
}
|
||||
|
||||
function Row({ r, p, facts, files, costs, t, locale }: {
|
||||
function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
|
||||
r: Reservation
|
||||
p: BookingsListProps
|
||||
facts: BookingFacts
|
||||
@@ -76,6 +76,7 @@ function Row({ r, p, facts, files, costs, t, locale }: {
|
||||
costs: CostTotal[]
|
||||
t: (k: string, v?: Record<string, string | number>) => string
|
||||
locale: string
|
||||
onNavigate: (e: KeyboardEvent<HTMLElement>) => void
|
||||
}) {
|
||||
const selected = p.selectedId === r.id
|
||||
const transit = r.type === 'transit'
|
||||
@@ -93,7 +94,10 @@ function Row({ r, p, facts, files, costs, t, locale }: {
|
||||
aria-pressed={selected}
|
||||
aria-label={displayTitle(r)}
|
||||
onClick={() => p.onSelect(r)}
|
||||
onKeyDown={e => { if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); p.onSelect(r) } }}
|
||||
onKeyDown={e => {
|
||||
if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); p.onSelect(r) }
|
||||
else onNavigate(e)
|
||||
}}
|
||||
className={`group relative grid cursor-pointer grid-cols-[22px_32px_minmax(0,1fr)_minmax(118px,auto)_auto] items-center gap-3 border-t border-edge-faint px-3.5 py-2.5 first:border-t-0 hover:bg-surface-hover focus-visible:outline-none focus-visible:bg-surface-hover ${selected ? 'bg-surface-hover shadow-[inset_3px_0_0_0_var(--text-primary)]' : ''}`}
|
||||
>
|
||||
<StatusDot r={r} canToggle={p.canEdit} onToggle={() => p.onToggleStatus(r)} />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { normalizePlaceWebsite, parsePlaceHours } from '@trek/shared';
|
||||
import { normalizePlaceWebsite, parsePlaceHours, stripPreviewTags } from '@trek/shared';
|
||||
import type { PlaceFormData } from './PlaceFormModal.helpers';
|
||||
import { cleanWeek, weekFromPeriods, writeWeek } from './placeHours';
|
||||
|
||||
@@ -23,8 +23,7 @@ const text = (value: unknown): string => (typeof value === 'string' ? value.trim
|
||||
|
||||
/** A description as plain words: the editor stores markup, the lookup sends text. */
|
||||
const plain = (value: string): string =>
|
||||
value
|
||||
.replace(/<[^>]*>/g, ' ')
|
||||
stripPreviewTags(value)
|
||||
.replace(/[*_`~#>]/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
@@ -2,6 +2,6 @@ import { Tooltip } from '../shared/Tooltip'
|
||||
|
||||
export default function SettingsHint({ children, id }: { children: string; id?: string }) {
|
||||
return <Tooltip label={children} placement="top">
|
||||
<p id={id} tabIndex={0} className="min-w-0 truncate text-caption leading-snug text-content-faint">{children}</p>
|
||||
<button type="button" id={id} className="block min-w-0 truncate text-start text-caption leading-snug text-content-faint">{children}</button>
|
||||
</Tooltip>
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ export default function ApiKeysSection(): React.ReactElement {
|
||||
placeholder={t('settings.apiKeys.modal.namePlaceholder')}
|
||||
maxLength={100}
|
||||
className={INPUT}
|
||||
autoFocus />
|
||||
data-initial-focus />
|
||||
</EditorField>
|
||||
|
||||
<section role="group" aria-labelledby="api-key-scopes-title">
|
||||
|
||||
@@ -420,7 +420,7 @@ function CreateTokenDialog({ S }: { S: IntegrationsState }) {
|
||||
onKeyDown={e => e.key === 'Enter' && handleCreateMcpToken()}
|
||||
placeholder={t('settings.mcp.modal.tokenNamePlaceholder')}
|
||||
className={INPUT}
|
||||
autoFocus />
|
||||
data-initial-focus />
|
||||
</EditorField>
|
||||
)}
|
||||
</DialogShell>
|
||||
@@ -453,17 +453,17 @@ function McpTokenModals({ S }: { S: IntegrationsState }) {
|
||||
*/
|
||||
function MachineClientSwitch({ checked, onChange, t }: { checked: boolean; onChange: (next: boolean) => void; t: IntegrationsState['t'] }) {
|
||||
return (
|
||||
<label htmlFor="oauth-machine-client" className="flex cursor-pointer items-center gap-4 rounded-[12px] border border-edge-faint bg-surface-card px-3.5 py-3">
|
||||
<div className="relative flex items-center gap-4 rounded-[12px] border border-edge-faint bg-surface-card px-3.5 py-3">
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block font-medium text-content" style={fs(13, 'body')}>{t('settings.oauth.modal.machineClient')}</span>
|
||||
<span className="mt-0.5 block leading-snug text-content-faint" style={fs(11.5)}>{t('settings.oauth.modal.machineClientHint')}</span>
|
||||
<label htmlFor="oauth-machine-client" className="block cursor-pointer font-medium text-content after:absolute after:inset-0" style={fs(13, 'body')}>{t('settings.oauth.modal.machineClient')}</label>
|
||||
<span id="oauth-machine-client-hint" className="mt-0.5 block leading-snug text-content-faint" style={fs(11.5)}>{t('settings.oauth.modal.machineClientHint')}</span>
|
||||
</span>
|
||||
<input id="oauth-machine-client" type="checkbox" checked={checked} onChange={e => onChange(e.target.checked)} className="peer sr-only" />
|
||||
<input id="oauth-machine-client" aria-describedby="oauth-machine-client-hint" type="checkbox" checked={checked} onChange={e => onChange(e.target.checked)} className="peer sr-only" />
|
||||
<span aria-hidden="true"
|
||||
className="relative h-6 w-11 flex-none rounded-full bg-[var(--border-primary)] transition-colors peer-checked:bg-accent peer-focus-visible:ring-2 peer-focus-visible:ring-[color:var(--text-primary)] peer-checked:[&>span]:left-[22px] peer-checked:[&>span]:bg-[var(--accent-text)]">
|
||||
<span className="absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-surface-card shadow-sm transition-[left]" />
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ function ClientForm({ S, labelId }: { S: IntegrationsState; labelId: string }) {
|
||||
<input id={`${labelId}-name`} type="text" value={oauthNewName} onChange={e => setOauthNewName(e.target.value)}
|
||||
placeholder={t('settings.oauth.modal.clientNamePlaceholder')}
|
||||
className={INPUT}
|
||||
autoFocus />
|
||||
data-initial-focus />
|
||||
</EditorField>
|
||||
|
||||
<MachineClientSwitch checked={oauthIsMachine} onChange={setOauthIsMachine} t={t} />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import React from 'react'
|
||||
import { Fingerprint, Plus, Trash2, Pencil, Check, X, AlertTriangle } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
@@ -56,7 +57,7 @@ export default function PasskeysSection({ demoMode }: { demoMode?: boolean }): R
|
||||
{pk.renamingId === c.id ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
type="text"
|
||||
value={pk.renameVal}
|
||||
onChange={e => pk.setRenameVal(e.target.value)}
|
||||
|
||||
@@ -19,10 +19,7 @@ function WatchSwitch({ W }: { W: WandererWatchController }) {
|
||||
// keeps its focus when the connection is known.
|
||||
return (
|
||||
<Tooltip label={t('wanderer.watch.notConnected')} disabled={!off}>
|
||||
<span
|
||||
tabIndex={off ? 0 : undefined}
|
||||
className={`inline-flex rounded-full outline-none ${off ? 'cursor-not-allowed opacity-50 focus-visible:ring-2 focus-visible:ring-[color:var(--text-primary)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--bg-card)]' : ''}`}
|
||||
>
|
||||
<span className={`relative inline-flex rounded-full ${off ? 'opacity-50' : ''}`}>
|
||||
<span className={`inline-flex ${off ? 'pointer-events-none' : ''}`}>
|
||||
<ToggleSwitch
|
||||
on={W.enabled}
|
||||
@@ -31,6 +28,14 @@ function WatchSwitch({ W }: { W: WandererWatchController }) {
|
||||
disabled={off}
|
||||
/>
|
||||
</span>
|
||||
{off && (
|
||||
<button
|
||||
type="button"
|
||||
aria-disabled="true"
|
||||
aria-label={t('wanderer.watch.notConnected')}
|
||||
className="absolute inset-0 cursor-not-allowed rounded-full outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--text-primary)]"
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { useState } from 'react'
|
||||
import { ChevronsDown, ChevronsUp, Copy, Lock, RotateCcw, RotateCw, Trash2, Unlock } from 'lucide-react'
|
||||
import type { BookElement, BookPageSetup, BookSpread } from '@trek/shared'
|
||||
@@ -304,7 +305,7 @@ export function StudioCanvas({
|
||||
return (
|
||||
<textarea
|
||||
className="st-inline-edit"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
defaultValue={el.text}
|
||||
style={{
|
||||
left: el.frame.x * scaled,
|
||||
|
||||
@@ -123,13 +123,13 @@ export function StudioFontPicker({
|
||||
close();
|
||||
};
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key !== 'Escape') return;
|
||||
if (e.key !== 'Escape' || !open) return;
|
||||
e.stopPropagation();
|
||||
close();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`st-fontpick ${open ? 'is-open' : ''}`} onKeyDown={onKey}>
|
||||
<div className={`st-fontpick ${open ? 'is-open' : ''}`}>
|
||||
<button
|
||||
ref={trigger}
|
||||
type="button"
|
||||
@@ -138,6 +138,7 @@ export function StudioFontPicker({
|
||||
aria-controls={listId}
|
||||
aria-label={`${t('journey.studio.fonts.change')}: ${current.name}`}
|
||||
onClick={() => (open ? close() : setOpen(true))}
|
||||
onKeyDown={onKey}
|
||||
>
|
||||
<span
|
||||
className="st-fontpick-face"
|
||||
@@ -156,18 +157,26 @@ export function StudioFontPicker({
|
||||
ref={search}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
onKeyDown={onKey}
|
||||
placeholder={t('journey.studio.fonts.search')}
|
||||
aria-label={t('journey.studio.fonts.search')}
|
||||
aria-controls={listId}
|
||||
spellCheck={false}
|
||||
/>
|
||||
{query && (
|
||||
<button type="button" onClick={() => setQuery('')} aria-label={t('common.clear')}>
|
||||
<button type="button" onClick={() => setQuery('')} onKeyDown={onKey} aria-label={t('common.clear')}>
|
||||
<X size={13} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div id={listId} className="st-fontpick-list" role="listbox" aria-label={t('journey.studio.fonts.list')}>
|
||||
<div
|
||||
id={listId}
|
||||
className="st-fontpick-list"
|
||||
role="listbox"
|
||||
tabIndex={-1}
|
||||
aria-label={t('journey.studio.fonts.list')}
|
||||
onKeyDown={onKey}
|
||||
>
|
||||
{!query && (
|
||||
<FontGroup
|
||||
label={t('journey.studio.fonts.used')}
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
type LucideIcon,
|
||||
} from 'lucide-react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
|
||||
import { useStudioStore } from '../../store/studioStore';
|
||||
import '../../styles/studio-layers.css';
|
||||
@@ -261,6 +262,7 @@ export function StudioLayersPanel({ t }: { t: T }) {
|
||||
ref={list}
|
||||
className={`st-layers ${drag?.active ? 'is-dragging' : ''}`}
|
||||
role="tree"
|
||||
tabIndex={-1}
|
||||
aria-label={t('journey.studio.layers')}
|
||||
onKeyDown={onTreeKey}
|
||||
onPointerMove={onPointerMove}
|
||||
@@ -448,7 +450,7 @@ function RowName(p: {
|
||||
return (
|
||||
<input
|
||||
className="st-input st-layer-input"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
defaultValue={p.named ? p.label : ''}
|
||||
placeholder={p.label}
|
||||
maxLength={60}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
type BookPatternPaint,
|
||||
} from '@trek/shared';
|
||||
import { ArrowLeftRight, Ban, Trash2 } from 'lucide-react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { useId, useRef, useState } from 'react';
|
||||
import '../../styles/studio-paint.css';
|
||||
import { NumField } from './StudioControls';
|
||||
import type { StudioT } from './StudioSidebar';
|
||||
@@ -350,13 +350,18 @@ function Slider({
|
||||
const pos = Math.round((log ? Math.log(value / min) / Math.log(max / min) : (value - min) / (max - min)) * steps);
|
||||
// What the slider was last moved to: a controlled input may still show the old value when it is let go.
|
||||
const moved = useRef(value);
|
||||
const fieldId = useId();
|
||||
return (
|
||||
<label className="st-paint-slider">
|
||||
<div className="st-paint-slider">
|
||||
<span className="st-paint-slider-head">
|
||||
<span className="st-paint-caption">{label}</span>
|
||||
<label htmlFor={fieldId} className="st-paint-caption">
|
||||
{label}
|
||||
</label>
|
||||
<span className="st-paint-value">{shown}</span>
|
||||
</span>
|
||||
<input
|
||||
id={fieldId}
|
||||
aria-valuetext={shown}
|
||||
type="range"
|
||||
min={0}
|
||||
max={steps}
|
||||
@@ -375,6 +380,6 @@ function Slider({
|
||||
onPointerUp={() => onChange(moved.current, true)}
|
||||
onKeyUp={() => onChange(moved.current, true)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { Fragment, useId, useState, useEffect, useEffectEvent, type CSSProperties } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
@@ -463,7 +464,7 @@ function NewTaskPane({ tripId, categories, members, defaultCategory, onCreated,
|
||||
<PaneHead title={t('todo.newItem')} onClose={onClose} />
|
||||
|
||||
<div style={FORM_BODY}>
|
||||
<input autoFocus value={name} onChange={e => setName(e.target.value)}
|
||||
<input ref={focusRevealedEditor} value={name} onChange={e => setName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter' && name.trim()) void create() }}
|
||||
style={{ ...taskInputStyle, fontSize: 'calc(15px * var(--fs-scale-subtitle, 1))', fontWeight: 600 }}
|
||||
placeholder={t('todo.namePlaceholder')} />
|
||||
|
||||
@@ -45,6 +45,7 @@ import { NavigationMenu } from '../shared/NavigationMenu';
|
||||
import { useToast } from '../shared/Toast';
|
||||
import { Tooltip } from '../shared/Tooltip';
|
||||
import TrackColorPicker from '../shared/TrackColorPicker';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import { markdownLinkComponents } from '../shared/markdownLink';
|
||||
import { TourDayRowAvatar } from './TourDayRowFacts';
|
||||
import { TourGpxExportButton } from './TourGpxExportButton';
|
||||
@@ -442,7 +443,7 @@ function TourNameHeading({
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={nameDraft}
|
||||
onChange={(event) => setNameDraft(event.target.value)}
|
||||
onKeyDown={(event) => {
|
||||
|
||||
@@ -21,8 +21,9 @@ function FactPill({ icon, label, info }: { icon?: ReactNode; label: string; info
|
||||
if (!info) return pill;
|
||||
return (
|
||||
<Tooltip label={info}>
|
||||
<span
|
||||
tabIndex={0}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={label}
|
||||
aria-describedby={id}
|
||||
className="inline-flex rounded-full focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent"
|
||||
>
|
||||
@@ -30,7 +31,7 @@ function FactPill({ icon, label, info }: { icon?: ReactNode; label: string; info
|
||||
<span id={id} className="sr-only">
|
||||
{info}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ function ListFilters({ library }: { library: TourLibrary }) {
|
||||
</label>
|
||||
<input
|
||||
id={searchId}
|
||||
autoFocus
|
||||
data-initial-focus
|
||||
value={library.filters.query}
|
||||
onChange={(event) => library.filter({ query: event.target.value })}
|
||||
placeholder={t('tours.library.search')}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Check, MapPinned, Search, X } from 'lucide-react';
|
||||
import { useId, useMemo, useState } from 'react';
|
||||
import { useId, useMemo, useState, type KeyboardEvent } from 'react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { useSettingsStore } from '../../../store/settingsStore';
|
||||
import { formatDistance } from '../../../utils/units';
|
||||
import { SoftPill } from '../../Planner/planParts';
|
||||
import { focusRevealedEditor } from '../../shared/dialogFocus';
|
||||
import { fs } from '../../shared/DialogShell';
|
||||
import PlaceAvatar from '../../shared/PlaceAvatar';
|
||||
import { NEAR_TOUR_M, type TripPlaceCandidate, type TripPlaceWaypoints } from './useTripPlaceWaypoints';
|
||||
@@ -16,10 +17,12 @@ function distanceLabel(metres: number, unit: 'metric' | 'imperial'): string {
|
||||
function CandidateRow({
|
||||
candidate,
|
||||
onPick,
|
||||
onDismissKey,
|
||||
unit,
|
||||
}: {
|
||||
candidate: TripPlaceCandidate;
|
||||
onPick: () => void;
|
||||
onDismissKey: (event: KeyboardEvent<HTMLElement>) => void;
|
||||
unit: 'metric' | 'imperial';
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
@@ -29,6 +32,7 @@ function CandidateRow({
|
||||
<button
|
||||
type="button"
|
||||
onClick={onPick}
|
||||
onKeyDown={onDismissKey}
|
||||
disabled={used}
|
||||
data-testid="trip-place-candidate"
|
||||
className="flex w-full items-center gap-2.5 rounded-[10px] px-2 py-1.5 text-start transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent enabled:hover:bg-surface-hover disabled:cursor-default"
|
||||
@@ -62,11 +66,13 @@ function CandidateRow({
|
||||
function CandidateGroup({
|
||||
title,
|
||||
candidates,
|
||||
onDismissKey,
|
||||
picker,
|
||||
unit,
|
||||
}: {
|
||||
title: string;
|
||||
candidates: TripPlaceCandidate[];
|
||||
onDismissKey: (event: KeyboardEvent<HTMLElement>) => void;
|
||||
picker: TripPlaceWaypoints;
|
||||
unit: 'metric' | 'imperial';
|
||||
}) {
|
||||
@@ -86,6 +92,7 @@ function CandidateGroup({
|
||||
candidate={candidate}
|
||||
unit={unit}
|
||||
onPick={() => picker.add(candidate.place)}
|
||||
onDismissKey={onDismissKey}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
@@ -114,17 +121,16 @@ export function TripPlacePicker({ picker, onClose }: { picker: TripPlaceWaypoint
|
||||
}, [picker.candidates, query]);
|
||||
const near = matches.filter((candidate) => candidate.distanceM != null && candidate.distanceM <= NEAR_TOUR_M);
|
||||
const further = matches.filter((candidate) => !near.includes(candidate));
|
||||
const onDismissKey = (event: KeyboardEvent<HTMLElement>) => {
|
||||
if (event.key !== 'Escape') return;
|
||||
event.stopPropagation();
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
data-testid="trip-place-picker"
|
||||
className="mt-1.5 overflow-hidden rounded-[12px] bg-surface-card shadow-sm ring-1 ring-inset ring-edge-faint"
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Escape') {
|
||||
event.stopPropagation();
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center gap-2 border-b border-edge-faint px-2.5 py-2">
|
||||
<Search size={13} strokeWidth={2.2} className="flex-none text-content-faint" />
|
||||
@@ -133,9 +139,10 @@ export function TripPlacePicker({ picker, onClose }: { picker: TripPlaceWaypoint
|
||||
</label>
|
||||
<input
|
||||
id={searchId}
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={query}
|
||||
onChange={(event) => setQuery(event.target.value)}
|
||||
onKeyDown={onDismissKey}
|
||||
placeholder={t('tours.placePicker.search')}
|
||||
className="min-w-0 flex-1 border-0 bg-transparent text-content outline-none placeholder:text-content-faint"
|
||||
style={fs(12.5, 'body')}
|
||||
@@ -143,6 +150,7 @@ export function TripPlacePicker({ picker, onClose }: { picker: TripPlaceWaypoint
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
onKeyDown={onDismissKey}
|
||||
aria-label={t('common.close')}
|
||||
className="grid h-6 w-6 flex-none place-items-center rounded-full text-content-faint transition-colors hover:bg-surface-hover hover:text-content"
|
||||
>
|
||||
@@ -161,10 +169,17 @@ export function TripPlacePicker({ picker, onClose }: { picker: TripPlaceWaypoint
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<CandidateGroup title={t('tours.placePicker.near')} candidates={near} picker={picker} unit={unit} />
|
||||
<CandidateGroup
|
||||
title={t('tours.placePicker.near')}
|
||||
candidates={near}
|
||||
picker={picker}
|
||||
unit={unit}
|
||||
onDismissKey={onDismissKey}
|
||||
/>
|
||||
<CandidateGroup
|
||||
title={near.length > 0 ? t('tours.placePicker.further') : t('tours.placePicker.all')}
|
||||
candidates={further}
|
||||
onDismissKey={onDismissKey}
|
||||
picker={picker}
|
||||
unit={unit}
|
||||
/>
|
||||
|
||||
@@ -119,7 +119,7 @@ describe('TripPlacePicker (PR1-10)', () => {
|
||||
expect(screen.getAllByTestId('trip-place-candidate')).toHaveLength(1);
|
||||
fireEvent.change(screen.getByPlaceholderText('tours.placePicker.search'), { target: { value: 'zzz' } });
|
||||
expect(screen.getByText('tours.placePicker.noMatch')).toBeInTheDocument();
|
||||
fireEvent.keyDown(screen.getByTestId('trip-place-picker'), { key: 'Escape' });
|
||||
fireEvent.keyDown(screen.getByPlaceholderText('tours.placePicker.search'), { key: 'Escape' });
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ function TrailSearch({ browser }: { browser: WandererBrowser }) {
|
||||
<input
|
||||
value={browser.query}
|
||||
onChange={(event) => browser.setQuery(event.target.value)}
|
||||
autoFocus
|
||||
placeholder={t('wanderer.browser.searchPlaceholder')}
|
||||
aria-label={t('wanderer.browser.searchPlaceholder')}
|
||||
className="min-w-0 flex-1 border-0 bg-transparent text-content outline-none placeholder:text-content-faint"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { useId, useState, type ComponentProps, type ReactNode } from 'react'
|
||||
import { Check, Copy, Crown, Link2, LogOut, Pencil, Plus, Puzzle, Settings, Trash2, UserMinus, UserPlus, UserRound, Users } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
@@ -328,7 +329,7 @@ function GuestsList({ m, onAsk }: { m: TripMembersState; onAsk: (ask: Ask) => vo
|
||||
<TripMemberAvatar username={g.username} avatarUrl={null} />
|
||||
{m.renamingGuestId === g.id ? (
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={m.renameValue}
|
||||
onChange={e => m.setRenameValue(e.target.value)}
|
||||
onKeyDown={e => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from './dialogFocus';
|
||||
import { Calendar, ChevronLeft, ChevronRight, Keyboard } from 'lucide-react';
|
||||
import { localIsoDate } from '../../utils/localDate';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
@@ -269,7 +270,7 @@ export function CustomDatePicker({
|
||||
<div ref={ref} style={{ position: 'relative', ...style }}>
|
||||
{isTyping ? (
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
type="text"
|
||||
value={textInput}
|
||||
onChange={(e) => setTextInput(e.target.value)}
|
||||
|
||||
@@ -252,7 +252,7 @@ export function DialogHeader(p: DialogHeaderProps) {
|
||||
onBlur={f.onBlur}
|
||||
aria-label={f.label}
|
||||
placeholder={f.placeholder}
|
||||
autoFocus={f.autoFocus}
|
||||
data-initial-focus={f.autoFocus || undefined}
|
||||
required={f.required}
|
||||
maxLength={f.maxLength}
|
||||
className="-mx-2 block w-[calc(100%+16px)] rounded-[10px] border-0 bg-transparent px-2 py-0.5 font-bold tracking-[-0.01em] text-content outline-none placeholder:font-semibold placeholder:text-content-faint hover:bg-surface-card focus:bg-surface-card focus:shadow-sm dark:bg-transparent dark:hover:bg-surface-card dark:focus:bg-surface-card"
|
||||
|
||||
@@ -43,6 +43,11 @@ function typingDevice(): boolean {
|
||||
return window.matchMedia('(pointer: fine)').matches && !isPhoneViewport()
|
||||
}
|
||||
|
||||
/** Give focus to a field revealed by an explicit edit or search action. */
|
||||
export function focusRevealedEditor(element: HTMLElement | null): void {
|
||||
element?.focus({ preventScroll: true })
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the focus into a dialog that just opened, unless something inside already
|
||||
* took it (a field with autoFocus, a dialog's own choice). The panel itself is
|
||||
|
||||
@@ -159,7 +159,7 @@ export default function MDayPager({
|
||||
// Still between pages: the snap has not finished, another event follows.
|
||||
if (!resting || resting.hasAttribute('data-page-active')) return;
|
||||
const raw = resting.dataset.dayId;
|
||||
const dayId = raw ? Number(raw) : NaN;
|
||||
const dayId = raw ? Number(raw) : Number.NaN;
|
||||
if (!Number.isFinite(dayId) || requested.current === dayId) return;
|
||||
requested.current = dayId;
|
||||
previewed = null;
|
||||
|
||||
@@ -72,7 +72,7 @@ function useEvenLines(listRef: RefObject<HTMLDivElement | null>) {
|
||||
const measure = () => {
|
||||
list.style.setProperty('--m-rail-lines', '1');
|
||||
const two = names().some((el) => {
|
||||
const line = parseFloat(getComputedStyle(el).lineHeight) || 0;
|
||||
const line = Number.parseFloat(getComputedStyle(el).lineHeight) || 0;
|
||||
return line > 0 && el.scrollHeight > line * 1.5;
|
||||
});
|
||||
list.style.setProperty('--m-rail-lines', two ? '2' : '1');
|
||||
|
||||
@@ -212,7 +212,7 @@ export default function MascotClip({
|
||||
>
|
||||
<canvas
|
||||
ref={canvasRef}
|
||||
aria-hidden
|
||||
inert
|
||||
className="pointer-events-none absolute"
|
||||
style={{
|
||||
left: `${x * 100}%` /* rtl-lint-disable: the crop sits where the frame was cut, video is never mirrored */,
|
||||
@@ -224,25 +224,25 @@ export default function MascotClip({
|
||||
<video
|
||||
key={loopUrl}
|
||||
ref={loopRef}
|
||||
inert
|
||||
src={loopUrl}
|
||||
autoPlay
|
||||
loop
|
||||
muted
|
||||
playsInline
|
||||
disablePictureInPicture
|
||||
aria-hidden
|
||||
style={HIDDEN_VIDEO}
|
||||
/>
|
||||
{pokeUrl && (
|
||||
<video
|
||||
key={pokeUrl}
|
||||
ref={pokeRef}
|
||||
inert
|
||||
src={pokeUrl}
|
||||
muted
|
||||
playsInline
|
||||
preload="auto"
|
||||
disablePictureInPicture
|
||||
aria-hidden
|
||||
style={HIDDEN_VIDEO}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -23,7 +23,6 @@ export default function MAdminCategoryManager() {
|
||||
onChange={e => setForm(prev => ({ ...prev, name: e.target.value }))}
|
||||
placeholder={t('categories.namePlaceholder')}
|
||||
className="h-[42px] w-full rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheetop)] px-3 text-[0.84375rem] text-m-ink outline-none placeholder:text-m-faint focus:border-[color:var(--m-faint)]"
|
||||
autoFocus
|
||||
/>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import Markdown from 'react-markdown';
|
||||
import remarkBreaks from 'remark-breaks';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { useOriginNotes } from '../../../components/Collections/useOriginNotes';
|
||||
import { focusRevealedEditor } from '../../../components/shared/dialogFocus';
|
||||
import { markdownLinkComponents } from '../../../components/shared/markdownLink';
|
||||
import type { TranslationFn } from '../../../types';
|
||||
import { CancelPill, PrimaryPill } from './MCollSheetKit';
|
||||
@@ -96,7 +97,7 @@ function MNoteEditor({ n, t }: { n: Notes; t: TranslationFn }) {
|
||||
</div>
|
||||
) : (
|
||||
<textarea
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
rows={6}
|
||||
value={n.draft}
|
||||
onChange={(e) => n.setDraft(e.target.value)}
|
||||
|
||||
@@ -75,7 +75,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
|
||||
const [railInset, setRailInset] = useState(0)
|
||||
useLayoutEffect(() => {
|
||||
const root = rootRef.current
|
||||
if (root) setRailInset(Math.max(0, -parseFloat(getComputedStyle(root).marginInlineStart) || 0))
|
||||
if (root) setRailInset(Math.max(0, -Number.parseFloat(getComputedStyle(root).marginInlineStart) || 0))
|
||||
}, [wide])
|
||||
const {
|
||||
id, navigate, toast, t, locale,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { replaceInlineMarkdownLinks } from '@trek/shared'
|
||||
import {
|
||||
SmilePlus, Smile, Meh, Frown,
|
||||
Sun, CloudSun, Cloud, CloudRain, CloudLightning, Snowflake,
|
||||
@@ -64,9 +65,8 @@ export function journeyCoverStyle(journey: { id: number; cover_image?: string |
|
||||
*/
|
||||
export function storyExcerpt(story: string | null | undefined): string {
|
||||
if (!story) return ''
|
||||
return story
|
||||
.replace(/!\[[^\]]*\]\([^)]*\)/g, '')
|
||||
.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
|
||||
const withoutImages = story.replace(/!\[[^\]]*\]\([^)]*\)/g, '')
|
||||
return replaceInlineMarkdownLinks(withoutImages, (label) => label, true)
|
||||
.replace(/[#>*_`~]+/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../../../../components/shared/dialogFocus'
|
||||
import { useEffect, useMemo, useState, type MouseEvent } from 'react'
|
||||
import { ArrowRight, BedDouble, CalendarDays, CalendarRange, ChevronRight, LogIn, LogOut, Map as MapIcon, MapPin, Pencil, PencilLine, Route, Ticket, TrainFront, Undo2 } from 'lucide-react'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
@@ -461,7 +462,7 @@ function EditHeader({ tl, planner, shell }: {
|
||||
<div className="flex flex-none items-center gap-2">
|
||||
{renaming ? (
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={draft}
|
||||
onChange={e => setDraft(e.target.value)}
|
||||
onBlur={commitRename}
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import CustomSelect from '../../../../components/shared/CustomSelect';
|
||||
import { focusRevealedEditor } from '../../../../components/shared/dialogFocus';
|
||||
import { LinkedJournalIcon } from '../../../../components/Trips/LinkedJournalIcon';
|
||||
import { TripJournalLinkSection } from '../../../../components/Trips/TripJournalLinkSection';
|
||||
import { TripMemberAvatar } from '../../../../components/Trips/TripMemberAvatar';
|
||||
@@ -313,7 +314,7 @@ function GuestRow({ guest, m, ask }: { guest: Members['guests'][number]; m: Memb
|
||||
if (m.renamingGuestId === guest.id) {
|
||||
return (
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={m.renameValue}
|
||||
maxLength={50}
|
||||
aria-label={t('common.rename')}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../../../../components/shared/dialogFocus'
|
||||
import { createElement, useState } from 'react'
|
||||
import { Ban, Check, ChevronDown, Plus, X } from 'lucide-react'
|
||||
import { getCategoryIcon } from '../../../../components/shared/categoryIcons'
|
||||
@@ -95,7 +96,7 @@ export default function PlCategoryPicker({ planner, value, onChange }: PlCategor
|
||||
}
|
||||
}}
|
||||
placeholder={t('places.categoryNamePlaceholder')}
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
className={`${FIELD_CLS} flex-1`}
|
||||
/>
|
||||
<button
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../../../../components/shared/dialogFocus'
|
||||
import { useState } from 'react'
|
||||
import { Check, Plus, X } from 'lucide-react'
|
||||
import type { PackingUpdateBagRequest } from '@trek/shared'
|
||||
@@ -105,7 +106,7 @@ export default function MBagsSheet({
|
||||
<div className="mt-3 flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={newBagName}
|
||||
onChange={e => setNewBagName(e.target.value)}
|
||||
onKeyDown={e => {
|
||||
@@ -167,7 +168,7 @@ function BagRow({ planner, bag, itemCount, weight, pct, tripMembers, canEdit, on
|
||||
{editingName && canEdit ? (
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={nameVal}
|
||||
onChange={e => setNameVal(e.target.value)}
|
||||
onBlur={saveName}
|
||||
@@ -186,7 +187,7 @@ function BagRow({ planner, bag, itemCount, weight, pct, tripMembers, canEdit, on
|
||||
<span>/</span>
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
inputMode="decimal"
|
||||
value={limitVal}
|
||||
aria-label={t('packing.bagLimit')}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../../../../components/shared/dialogFocus'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
@@ -480,7 +481,7 @@ function NoteFormSheet({ open, target, categories, colorMap, canUploadFiles, onC
|
||||
{addingCategory ? (
|
||||
<div className="flex items-center gap-[4px]">
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={newCategoryDraft}
|
||||
onChange={e => setNewCategoryDraft(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); confirmNewCategory() } }}
|
||||
|
||||
@@ -302,7 +302,7 @@ function DetailView({
|
||||
if (next) void sync.updateLink(link.id, { direction: next })
|
||||
}
|
||||
|
||||
const ranAt = link.lastSyncAt ? Date.parse(link.lastSyncAt) : NaN
|
||||
const ranAt = link.lastSyncAt ? Date.parse(link.lastSyncAt) : Number.NaN
|
||||
const notice = bindingNotice(link, t)
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../../../../components/shared/dialogFocus'
|
||||
import { useMemo, useState, type ReactNode } from 'react'
|
||||
import { selectionHaptic } from '../../../../native/haptics'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
@@ -143,7 +144,7 @@ export default function MPackingListTab({ planner }: { planner: TripPlanner }) {
|
||||
<div className="mt-[10px] flex items-center gap-1.5 rounded-[16px] border border-m-rowbr bg-m-card py-[5px] pe-[5px] ps-[14px]">
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={newCategoryName}
|
||||
onChange={e => setNewCategoryName(e.target.value)}
|
||||
onKeyDown={e => {
|
||||
@@ -309,7 +310,7 @@ export default function MPackingListTab({ planner }: { planner: TripPlanner }) {
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={saveTemplateName}
|
||||
onChange={e => setSaveTemplateName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void saveAsTemplate() }}
|
||||
@@ -529,7 +530,7 @@ function PackingCategoryCard({
|
||||
{renaming ? (
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={renameDraft ?? group.category}
|
||||
onChange={e => setRenameDraft(e.target.value)}
|
||||
onBlur={commitRename}
|
||||
@@ -589,7 +590,7 @@ function PackingCategoryCard({
|
||||
<span aria-hidden className="h-[22px] w-[22px] flex-none rounded-[7px] border-[1.5px] border-[color:var(--m-checkbr)]" />
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={newItemName}
|
||||
onChange={e => setNewItemName(e.target.value)}
|
||||
onBlur={() => { if (!newItemName.trim()) { setAddingItem(false); setNewItemName('') } }}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { focusRevealedEditor } from '../../../../components/shared/dialogFocus'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Check, Flag, Plus, User } from 'lucide-react'
|
||||
import type { TodoCreateItemRequest } from '@trek/shared'
|
||||
@@ -175,7 +176,7 @@ export default function MTaskSheet({ planner, open, itemId, categories, members,
|
||||
<div className="mt-1 flex w-full items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={categoryDraft}
|
||||
onChange={e => setCategoryDraft(e.target.value)}
|
||||
onKeyDown={e => {
|
||||
|
||||
@@ -125,7 +125,7 @@ export function TabPanes({ aside, asideLabel, children }: { aside: ReactNode; as
|
||||
|
||||
/** Where the list starts in its scroll body's content, under the body's top padding. */
|
||||
function listStartIn(el: HTMLElement, top: HTMLElement): number {
|
||||
const pad = parseFloat(getComputedStyle(el).paddingTop) || 0
|
||||
const pad = Number.parseFloat(getComputedStyle(el).paddingTop) || 0
|
||||
return top.getBoundingClientRect().top - el.getBoundingClientRect().top - pad + el.scrollTop
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { stripTrailingSlashes } from '@trek/shared';
|
||||
import { detectAuthGate, type AuthGate } from './authGate';
|
||||
import { DEMO_SERVER_URL } from './links';
|
||||
|
||||
@@ -59,7 +60,7 @@ function normalize(raw: string): string | null {
|
||||
return null;
|
||||
}
|
||||
if ((parsed.protocol !== 'https:' && parsed.protocol !== 'http:') || !parsed.hostname) return null;
|
||||
return parsed.origin + parsed.pathname.replace(/\/+$/, '');
|
||||
return parsed.origin + stripTrailingSlashes(parsed.pathname);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -145,7 +145,6 @@ function ResetPasswordPage() {
|
||||
type="text" inputMode="numeric" value={mfaCode}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) => setMfaCode(e.target.value)}
|
||||
required placeholder="123456 or backup-code" style={{ ...inputBase, paddingInlineEnd: 12 }}
|
||||
autoFocus
|
||||
onFocus={(e) => { e.currentTarget.style.borderColor = '#111827' }}
|
||||
onBlur={(e) => { e.currentTarget.style.borderColor = '#e5e7eb' }}
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ChevronLeft, ChevronRight, Loader2, MapPin, PenLine, Search, Sparkles, Star, X } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { focusRevealedEditor } from '../../components/shared/dialogFocus';
|
||||
import { fs } from '../../components/shared/DialogShell';
|
||||
import { HUB_CARD, HUB_FIELD, HUB_INSET, HubGhost, HubGlow, HubIconButton, HubPrimary } from './atlasHubKit';
|
||||
import type { AtlasGlobeState } from './useAtlasGlobe';
|
||||
@@ -85,7 +86,7 @@ export default function AtlasGlobeWishAdd({ s }: { s: AtlasGlobeState }): React.
|
||||
className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-muted"
|
||||
/>
|
||||
<input
|
||||
autoFocus
|
||||
ref={focusRevealedEditor}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
|
||||
@@ -133,7 +133,7 @@ export function paintGlobe(engine: GlobeEngine, input: GlobePaintInput): void {
|
||||
const r = engine.renderer;
|
||||
const byCode = new Map((input.data?.countries ?? []).map((c) => [c.code, c]));
|
||||
const visitYears = (input.data?.countries ?? [])
|
||||
.map((c) => (c.firstVisit ? Number(c.firstVisit.slice(0, 4)) : NaN))
|
||||
.map((c) => (c.firstVisit ? Number(c.firstVisit.slice(0, 4)) : Number.NaN))
|
||||
.filter((y) => !Number.isNaN(y));
|
||||
const firstYear = visitYears.length ? Math.min(...visitYears) : new Date().getFullYear();
|
||||
const lastYear = visitYears.length ? Math.max(...visitYears) : firstYear;
|
||||
|
||||
@@ -431,7 +431,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
|
||||
for (const rows of Object.values(regions))
|
||||
regionCount += rows.filter((r) => (r.status ?? 'visited') === 'visited').length;
|
||||
const years = visited
|
||||
.map((c) => (c.firstVisit ? Number(c.firstVisit.slice(0, 4)) : NaN))
|
||||
.map((c) => (c.firstVisit ? Number(c.firstVisit.slice(0, 4)) : Number.NaN))
|
||||
.filter((y) => !Number.isNaN(y));
|
||||
const perYear = new Map<number, number>();
|
||||
for (const y of years) perYear.set(y, (perYear.get(y) ?? 0) + 1);
|
||||
|
||||
@@ -44,8 +44,8 @@ export async function findOnMap(queries: string[], lang?: string): Promise<MapMa
|
||||
/** One search hit as a match, or null when it has no coordinates to put on the map. */
|
||||
function toMatch(row: unknown, query: string): MapMatch | null {
|
||||
const place = row as { lat?: unknown; lng?: unknown; name?: unknown; address?: unknown };
|
||||
const lat = typeof place.lat === 'number' ? place.lat : NaN;
|
||||
const lng = typeof place.lng === 'number' ? place.lng : NaN;
|
||||
const lat = typeof place.lat === 'number' ? place.lat : Number.NaN;
|
||||
const lng = typeof place.lng === 'number' ? place.lng : Number.NaN;
|
||||
if (!Number.isFinite(lat) || !Number.isFinite(lng)) return null;
|
||||
const parts = [place.name, place.address].filter((v): v is string => typeof v === 'string' && v.trim() !== '');
|
||||
const address = typeof place.address === 'string' && place.address.trim() ? place.address : undefined;
|
||||
|
||||
@@ -23,7 +23,7 @@ export function normalizeHex(raw: string): string | null {
|
||||
|
||||
export function hexToHsv(hex: string): Hsv {
|
||||
const norm = normalizeHex(hex) ?? '#000000';
|
||||
const [r, g, b] = [1, 3, 5].map((i) => parseInt(norm.slice(i, i + 2), 16) / 255);
|
||||
const [r, g, b] = [1, 3, 5].map((i) => Number.parseInt(norm.slice(i, i + 2), 16) / 255);
|
||||
const max = Math.max(r, g, b);
|
||||
const d = max - Math.min(r, g, b);
|
||||
let h = 0;
|
||||
|
||||
Reference in New Issue
Block a user