diff --git a/packages/i18n/locales/el/common.json b/packages/i18n/locales/el/common.json index dbbc53c..e526854 100644 --- a/packages/i18n/locales/el/common.json +++ b/packages/i18n/locales/el/common.json @@ -34,7 +34,12 @@ "pinProgress": "{{count}} από {{total}} ψηφία", "submit": "OK", "decrease": "Λιγότερο", - "increase": "Περισσότερο" + "increase": "Περισσότερο", + "search": "Αναζήτηση", + "clear": "Καθαρισμός", + "all": "Όλα", + "noOptions": "Δεν βρέθηκε τίποτα", + "selected": "{{count}} επιλεγμένα" }, "override": { "title": "Έγκριση υπευθύνου", diff --git a/packages/i18n/locales/en/common.json b/packages/i18n/locales/en/common.json index 8703863..b03a4a5 100644 --- a/packages/i18n/locales/en/common.json +++ b/packages/i18n/locales/en/common.json @@ -34,7 +34,12 @@ "pinProgress": "{{count}} of {{total}} digits entered", "submit": "OK", "decrease": "Less", - "increase": "More" + "increase": "More", + "search": "Search", + "clear": "Clear", + "all": "All", + "noOptions": "Nothing found", + "selected": "{{count}} selected" }, "override": { "title": "Manager approval", diff --git a/packages/i18n/src/hooks.js b/packages/i18n/src/hooks.js index e51b8cc..9afa74c 100644 --- a/packages/i18n/src/hooks.js +++ b/packages/i18n/src/hooks.js @@ -37,6 +37,11 @@ export function useUiLabels() { decrease: t('ui.decrease'), increase: t('ui.increase'), submit: t('ui.submit'), + search: t('ui.search'), + clear: t('ui.clear'), + all: t('ui.all'), + noOptions: t('ui.noOptions'), + selected: count => t('ui.selected', { count }), pinProgress: (count, total) => t('ui.pinProgress', { count, total }), }), [t, language]) // eslint-disable-line react-hooks/exhaustive-deps } diff --git a/packages/ui/src/components.css b/packages/ui/src/components.css index 755c374..c0ee0f8 100644 --- a/packages/ui/src/components.css +++ b/packages/ui/src/components.css @@ -10,7 +10,7 @@ overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; } -.x-dialog, .x-sheet, .x-toast, .x-input, .x-select__control { color-scheme: var(--x-color-scheme); } +.x-dialog, .x-sheet, .x-toast, .x-input, .x-select__control, .x-dropdown__menu { color-scheme: var(--x-color-scheme); } /* ── Spinner ─────────────────────────────────────────────────────────────── */ .x-spinner { display: inline-flex; flex-shrink: 0; color: currentColor; } @@ -81,6 +81,7 @@ .x-dialog--sm { max-width: 400px; } .x-dialog--md { max-width: 520px; } .x-dialog--lg { max-width: 720px; } +.x-dialog--xl { max-width: 920px; } .x-sheet--bottom { width: 100%; max-width: 640px; max-height: 90vh; @@ -334,3 +335,166 @@ /* always light behind the code, in dark themes too: scanners need the contrast */ .x-qr__tile { padding: var(--x-space-3); border-radius: var(--x-radius-card); border: var(--x-border-width) solid var(--x-line); background: var(--x-on-colour); line-height: 0; } .x-qr__caption { font-size: var(--x-text-label); color: var(--x-ink-2); text-align: center; } + +/* ── Page, PageHeader, Toolbar (the page rule, 2026-11-20) ───────────────── + * A page scrolls on its own and is as wide as a 16:9 screen allows, centred beyond. */ +.x-page { display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0; } +.x-page__top { flex-shrink: 0; border-bottom: var(--x-border-width) solid var(--x-line); background: var(--x-surface); } +.x-page__top-inner { box-sizing: border-box; width: 100%; max-width: var(--x-page-max); margin-inline: auto; padding: 0 var(--x-page-pad); } +.x-page__scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; } +.x-page__body { + box-sizing: border-box; width: 100%; max-width: var(--x-page-max); margin-inline: auto; + padding: var(--x-page-pad); + display: grid; gap: var(--x-page-gap); align-content: start; grid-template-columns: minmax(0, 1fr); +} +.x-page__body--form { max-width: var(--x-page-form-max); } +.x-page__top-inner.x-page__body--form { padding-top: 0; padding-bottom: 0; } +.x-page__body--flush { padding: 0; } +@media (max-width: 768px) { + .x-page__body, .x-page__top-inner { padding-inline: var(--x-space-4); } + .x-page__body { padding-block: var(--x-space-4); } + .x-page__body--flush { padding: 0; } +} + +.x-page-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--x-space-3); } +.x-page-header__titles { flex: 1; min-width: 0; } +.x-page-header__title { margin: 0; display: flex; align-items: center; gap: var(--x-space-1); font-size: var(--x-text-title); line-height: var(--x-leading-title); font-weight: var(--x-weight-semibold); color: var(--x-ink); } +.x-page-header__subtitle { margin: var(--x-space-0-5) 0 0; font-size: var(--x-text-label); line-height: var(--x-leading-label); color: var(--x-ink-2); } +.x-page-header__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--x-space-2); } + +.x-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--x-space-2); } +.x-toolbar > .x-search { flex: 1 1 16rem; } +.x-toolbar__spacer { flex: 1; } + +/* ── SearchInput ─────────────────────────────────────────────────────────── */ +.x-search { position: relative; display: block; min-width: 12rem; } +.x-search__icon { position: absolute; left: var(--x-space-3); top: 50%; transform: translateY(-50%); display: flex; color: var(--x-ink-3); pointer-events: none; } +.x-search__input { padding-left: var(--x-space-10); padding-right: var(--x-space-10); } +.x-search__input::-webkit-search-cancel-button { display: none; } +.x-search__clear { + position: absolute; right: var(--x-space-2); top: 50%; transform: translateY(-50%); + display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; + border: 0; border-radius: var(--x-radius-full); background: transparent; color: var(--x-ink-3); cursor: pointer; +} +.x-search__clear:hover { background: var(--x-surface-2); color: var(--x-ink); } +.x-search__clear:focus-visible { outline: none; box-shadow: var(--x-focus-ring); } + +/* ── Dropdown ────────────────────────────────────────────────────────────── */ +.x-dropdown { + display: inline-flex; align-items: center; gap: var(--x-space-2); + box-sizing: border-box; min-width: 10rem; max-width: 100%; + min-height: var(--x-control-md); padding: 0 var(--x-space-3); + background: var(--x-surface); color: var(--x-ink); + border: var(--x-border-width) solid var(--x-line-strong); border-radius: var(--x-radius-control); + font: inherit; font-size: var(--x-text-body); line-height: var(--x-leading-body); text-align: left; + cursor: pointer; color-scheme: var(--x-color-scheme); + transition: border-color var(--x-duration-fast) var(--x-ease), box-shadow var(--x-duration-fast) var(--x-ease); +} +.x-dropdown:hover:not(:disabled) { border-color: var(--x-ink-3); } +.x-dropdown:focus-visible, .x-dropdown--open { outline: none; border-color: var(--x-accent); box-shadow: var(--x-focus-ring); } +.x-dropdown:disabled { background: var(--x-surface-2); color: var(--x-ink-3); cursor: not-allowed; } +.x-dropdown--sm { min-height: var(--x-control-sm); } +.x-dropdown--lg { min-height: var(--x-control-lg); font-size: var(--x-text-body-lg); } +.x-dropdown--filtered { border-color: var(--x-accent); background: var(--x-accent-soft); color: var(--x-accent-ink); } +.x-dropdown__icon { display: flex; color: var(--x-ink-3); } +.x-dropdown--filtered .x-dropdown__icon, .x-dropdown--filtered .x-dropdown__chevron { color: inherit; } +.x-dropdown__value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--x-weight-medium); } +.x-dropdown__value--placeholder { color: var(--x-ink-3); font-weight: var(--x-weight-regular); } +.x-dropdown__count { padding: 0 var(--x-space-1-5); border-radius: var(--x-radius-full); background: var(--x-accent); color: var(--x-accent-fg); font-size: var(--x-text-caption); font-weight: var(--x-weight-bold); } +.x-dropdown__chevron { flex-shrink: 0; color: var(--x-ink-3); transition: transform var(--x-duration-fast) var(--x-ease); } +.x-dropdown--open .x-dropdown__chevron { transform: rotate(180deg); } + +.x-dropdown__menu { + position: fixed; z-index: var(--x-z-popover); box-sizing: border-box; + display: flex; flex-direction: column; max-width: min(420px, calc(100vw - 16px)); overflow: hidden; + background: var(--x-surface); color: var(--x-ink); + border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-card); + box-shadow: var(--x-shadow-popover); outline: none; + animation: x-fade-in var(--x-duration-fast) var(--x-ease); +} +.x-dropdown__search { padding: var(--x-space-2); border-bottom: var(--x-border-width) solid var(--x-line); } +.x-dropdown__list { list-style: none; margin: 0; padding: var(--x-space-1); overflow-y: auto; min-height: 0; } +.x-dropdown__option { + display: flex; align-items: center; gap: var(--x-space-2-5); + min-height: 38px; padding: var(--x-space-1-5) var(--x-space-3); border-radius: var(--x-radius-sm); + font-size: var(--x-text-body); line-height: var(--x-leading-body); cursor: pointer; user-select: none; +} +.x-dropdown__option--active { background: var(--x-surface-2); } +.x-dropdown__option--on { font-weight: var(--x-weight-semibold); } +.x-dropdown__option--disabled { opacity: 0.45; cursor: not-allowed; } +.x-dropdown__text { flex: 1; min-width: 0; display: grid; } +.x-dropdown__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.x-dropdown__hint { font-size: var(--x-text-caption); line-height: var(--x-leading-caption); color: var(--x-ink-3); font-weight: var(--x-weight-regular); } +.x-dropdown__tick { display: flex; color: var(--x-accent); } +.x-dropdown__dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; } +.x-dropdown__box { + display: flex; align-items: center; justify-content: center; flex-shrink: 0; + width: 18px; height: 18px; box-sizing: border-box; + border: 1.5px solid var(--x-line-strong); border-radius: 5px; background: var(--x-surface); color: var(--x-accent-fg); +} +.x-dropdown__box--on { background: var(--x-accent); border-color: var(--x-accent); } +.x-dropdown__none { padding: var(--x-space-3); font-size: var(--x-text-label); color: var(--x-ink-3); text-align: center; } +.x-dropdown__foot { padding: var(--x-space-1-5) var(--x-space-2); border-top: var(--x-border-width) solid var(--x-line); } +.x-dropdown__clear { + width: 100%; padding: var(--x-space-1-5) var(--x-space-2); border: 0; border-radius: var(--x-radius-sm); + background: transparent; color: var(--x-accent-ink); font: inherit; font-size: var(--x-text-label); font-weight: var(--x-weight-semibold); text-align: left; cursor: pointer; +} +.x-dropdown__clear:hover { background: var(--x-surface-2); } + +/* ── FilterChip ──────────────────────────────────────────────────────────── */ +.x-chip { + --x-chip-tone: var(--x-ink-3); --x-chip-soft: var(--x-surface-2); --x-chip-ink: var(--x-ink-2); + display: inline-flex; align-items: center; gap: var(--x-space-2); + box-sizing: border-box; min-height: var(--x-control-md); padding: 0 var(--x-space-4); + border: var(--x-border-width) solid var(--x-line-strong); border-radius: var(--x-radius-full); + background: var(--x-surface); color: var(--x-ink-2); + font: inherit; font-size: var(--x-text-label); font-weight: var(--x-weight-semibold); white-space: nowrap; cursor: pointer; + transition: background-color var(--x-duration-fast) var(--x-ease), border-color var(--x-duration-fast) var(--x-ease); +} +.x-chip--sm { min-height: var(--x-control-sm); padding: 0 var(--x-space-3); } +.x-chip:hover { background: var(--x-surface-2); } +.x-chip:focus-visible { outline: none; box-shadow: var(--x-focus-ring); } +.x-chip__dot { width: 8px; height: 8px; border-radius: var(--x-radius-full); background: var(--x-chip-tone); } +.x-chip__count { color: var(--x-ink); font-variant-numeric: tabular-nums; } +.x-chip--on, .x-chip--on:hover { background: var(--x-chip-soft); color: var(--x-chip-ink); border-color: var(--x-chip-tone); } +.x-chip--on .x-chip__count { color: inherit; } +.x-chip--success { --x-chip-tone: var(--x-success); --x-chip-soft: var(--x-success-soft); --x-chip-ink: var(--x-success-ink); } +.x-chip--info { --x-chip-tone: var(--x-info); --x-chip-soft: var(--x-info-soft); --x-chip-ink: var(--x-info-ink); } +.x-chip--accent { --x-chip-tone: var(--x-accent); --x-chip-soft: var(--x-accent-soft); --x-chip-ink: var(--x-accent-ink); } +.x-chip--warning { --x-chip-tone: var(--x-warning); --x-chip-soft: var(--x-warning-soft); --x-chip-ink: var(--x-warning-ink); } +.x-chip--danger { --x-chip-tone: var(--x-danger); --x-chip-soft: var(--x-danger-soft); --x-chip-ink: var(--x-danger-ink); } + +/* ── Segmented ───────────────────────────────────────────────────────────── */ +.x-segmented { + display: inline-flex; box-sizing: border-box; min-height: var(--x-control-md); padding: 3px; gap: 2px; + border: var(--x-border-width) solid var(--x-line-strong); border-radius: var(--x-radius-control); background: var(--x-surface-2); +} +.x-segmented--sm { min-height: var(--x-control-sm); } +.x-segmented__item { + display: inline-flex; align-items: center; gap: var(--x-space-1-5); padding: 0 var(--x-space-3); + border: 0; border-radius: calc(var(--x-radius-control) - 3px); background: transparent; color: var(--x-ink-2); + font: inherit; font-size: var(--x-text-label); font-weight: var(--x-weight-medium); cursor: pointer; +} +.x-segmented__item:hover { color: var(--x-ink); } +.x-segmented__item:focus-visible { outline: none; box-shadow: var(--x-focus-ring); } +.x-segmented__item--on, .x-segmented__item--on:hover { background: var(--x-surface); color: var(--x-ink); font-weight: var(--x-weight-semibold); box-shadow: var(--x-shadow-raised); } + +/* ── Tabs ────────────────────────────────────────────────────────────────── */ +.x-tabs { display: flex; align-items: center; gap: var(--x-space-2); box-shadow: inset 0 calc(-1 * var(--x-border-width)) 0 var(--x-line); } +.x-page__top .x-tabs { box-shadow: none; } +.x-tabs__list { flex: 1; min-width: 0; display: flex; gap: var(--x-space-1); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; } +.x-tabs__list::-webkit-scrollbar { display: none; } +.x-tabs__tab { + display: inline-flex; align-items: center; gap: var(--x-space-1-5); flex-shrink: 0; + padding: var(--x-space-2-5) var(--x-space-3); border: 0; background: transparent; + box-shadow: inset 0 -2px 0 transparent; color: var(--x-ink-2); + font: inherit; font-size: var(--x-text-label); font-weight: var(--x-weight-medium); white-space: nowrap; cursor: pointer; + transition: color var(--x-duration-fast) var(--x-ease), box-shadow var(--x-duration-fast) var(--x-ease); +} +.x-tabs--lg .x-tabs__tab { padding: var(--x-space-3) var(--x-space-4); font-size: var(--x-text-body); } +.x-tabs__tab:hover { color: var(--x-ink); } +.x-tabs__tab:focus-visible { outline: none; box-shadow: var(--x-focus-ring); } +.x-tabs__tab--on, .x-tabs__tab--on:hover { color: var(--x-ink); font-weight: var(--x-weight-semibold); box-shadow: inset 0 -2px 0 var(--x-accent); } +.x-tabs__badge { min-width: 18px; padding: 0 var(--x-space-1-5); box-sizing: border-box; border-radius: var(--x-radius-full); background: var(--x-surface-2); color: var(--x-ink-2); font-size: var(--x-text-caption); font-weight: var(--x-weight-bold); text-align: center; font-variant-numeric: tabular-nums; } +.x-tabs__badge--warn { background: var(--x-danger-soft); color: var(--x-danger-ink); } +.x-tabs__end { flex-shrink: 0; display: flex; align-items: center; gap: var(--x-space-2); } diff --git a/packages/ui/src/components/Controls.jsx b/packages/ui/src/components/Controls.jsx new file mode 100644 index 0000000..73c7ed8 --- /dev/null +++ b/packages/ui/src/components/Controls.jsx @@ -0,0 +1,82 @@ +import { cx } from '../internal/cx.js' +import { useLabels } from './labels.js' + +const SearchIcon = () => ( + +) +const ClearIcon = () => ( + +) + +/** + * A search box: icon, input, a clear button while there is text. Same heights as . + * + * onChange receives the text (not an event). Grows to fill a . + */ +export function SearchInput({ value = '', onChange, placeholder, size = 'md', className, 'aria-label': ariaLabel, ...rest }) { + const labels = useLabels() + return ( +
+ + onChange?.(e.target.value)} {...rest} /> + {value && ( + + )} +
+ ) +} + +/** + * A toggle filter in a toolbar: a state, a status… with an optional coloured dot and a count. + * tone: 'success' | 'info' | 'accent' | 'warning' | 'danger' | 'neutral' (the dot and the "on" look). + */ +export function FilterChip({ pressed = false, tone = 'neutral', count, size = 'md', className, children, ...rest }) { + return ( + + ) +} + +/** + * A few mutually exclusive views (List / Map). options: [{ value, label, icon? }]. + * + */ +export function Segmented({ options = [], value, onChange, size = 'md', className, ...rest }) { + return ( +
+ {options.map(o => ( + + ))} +
+ ) +} + +/** + * Tabs with an underline: a page's or a dialog's sections. Scrolls sideways when they don't fit, + * never up and down. tabs: [{ id, label, badge?, warn?, testId? }]. + * + * end: an element at the right end of the strip (a refresh button…). + */ +export function Tabs({ tabs = [], value, onChange, size = 'md', end, className, ...rest }) { + return ( +
+
+ {tabs.map(tb => ( + + ))} +
+ {end &&
{end}
} +
+ ) +} diff --git a/packages/ui/src/components/Dropdown.jsx b/packages/ui/src/components/Dropdown.jsx new file mode 100644 index 0000000..23cdec2 --- /dev/null +++ b/packages/ui/src/components/Dropdown.jsx @@ -0,0 +1,183 @@ +import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react' +import { cx } from '../internal/cx.js' +import { Portal } from '../internal/Portal.jsx' +import { useLabels } from './labels.js' + +const GAP = 6 +const MARGIN = 8 + +const Chevron = () => ( + +) +const Tick = () => ( + +) + +/** + * The one dropdown of the product (2026-11-20): single or multiple choice, a floating list + * (portal, flips above when there's no room), keyboard (↑ ↓ Enter Escape), a search box for long + * lists. Same heights as (size 'sm' | 'md' | 'lg'), so it lines up with a search bar. + * + * + * + * + * multiple: value is an array; an empty array means "all" (shown as allLabel) — the usual filter. + * options: [{ value, label, hint?, dot? (a colour the venue chose, e.g. a zone's), disabled? }]. + * onChange receives the new value (not an event). searchable: default when > 8 options. + * icon: an element shown before the text (a filter icon…). + */ +export function Dropdown({ + options = [], value, onChange, multiple = false, placeholder, allLabel, size = 'md', + searchable, icon, disabled = false, className, menuClassName, id, ...rest +}) { + const labels = useLabels() + const [open, setOpen] = useState(false) + const [pos, setPos] = useState(null) + const [query, setQuery] = useState('') + const [active, setActive] = useState(0) + const button = useRef(null) + const menu = useRef(null) + const search = useRef(null) + const listId = useId() + const chosen = multiple ? (Array.isArray(value) ? value : []) : value + const isOn = v => (multiple ? chosen.includes(v) : chosen === v) + const withSearch = searchable ?? options.length > 8 + + const shown = useMemo(() => { + const q = query.trim().toLocaleLowerCase() + return q ? options.filter(o => String(o.label).toLocaleLowerCase().includes(q)) : options + }, [options, query]) + + const place = useCallback(() => { + const b = button.current?.getBoundingClientRect() + const m = menu.current?.getBoundingClientRect() + if (!b) return + const height = m?.height ?? 0 + const below = window.innerHeight - b.bottom - GAP - MARGIN + const above = b.top - GAP - MARGIN + const up = height > below && above > below + const width = Math.max(b.width, m?.width ?? 0) + const left = Math.min(Math.max(MARGIN, b.left), window.innerWidth - MARGIN - width) + setPos({ left, minWidth: b.width, top: up ? undefined : b.bottom + GAP, bottom: up ? window.innerHeight - b.top + GAP : undefined, maxHeight: Math.max(160, up ? above : below) }) + }, []) + + useLayoutEffect(() => { if (open) place() }, [open, place, shown.length]) + + useEffect(() => { + if (!open) return + const onDown = e => { + if (button.current?.contains(e.target) || menu.current?.contains(e.target)) return + setOpen(false) + } + const onScroll = e => { if (!menu.current?.contains(e.target)) place() } + document.addEventListener('pointerdown', onDown) + window.addEventListener('resize', place) + window.addEventListener('scroll', onScroll, true) + return () => { + document.removeEventListener('pointerdown', onDown) + window.removeEventListener('resize', place) + window.removeEventListener('scroll', onScroll, true) + } + }, [open, place]) + + useEffect(() => { + if (!open) return + setQuery('') + const first = options.findIndex(o => isOn(o.value)) + setActive(first >= 0 ? first : 0) + requestAnimationFrame(() => (search.current ?? menu.current)?.focus()) + }, [open]) // eslint-disable-line react-hooks/exhaustive-deps + + useEffect(() => { + menu.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView({ block: 'nearest' }) + }, [active]) + + function pick(o) { + if (!o || o.disabled) return + if (multiple) { + onChange?.(isOn(o.value) ? chosen.filter(v => v !== o.value) : [...chosen, o.value]) + } else { + onChange?.(o.value) + setOpen(false) + button.current?.focus() + } + } + + function onKey(e) { + if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setOpen(false); button.current?.focus() } + else if (e.key === 'Tab') setOpen(false) + else if (e.key === 'ArrowDown') { e.preventDefault(); setActive(i => Math.min(shown.length - 1, i + 1)) } + else if (e.key === 'ArrowUp') { e.preventDefault(); setActive(i => Math.max(0, i - 1)) } + else if (e.key === 'Enter' || (e.key === ' ' && e.target !== search.current)) { e.preventDefault(); pick(shown[active]) } + } + + const label = (() => { + if (!multiple) return options.find(o => o.value === chosen)?.label + if (chosen.length === 0) return allLabel ?? placeholder + const names = options.filter(o => chosen.includes(o.value)).map(o => o.label) + return names.length === options.length && allLabel ? allLabel : names.join(', ') + })() + const empty = multiple ? chosen.length === 0 && !allLabel : label == null + + return ( + <> + + {open && ( + +
+ {withSearch && ( +
+ { setQuery(e.target.value); setActive(0) }} /> +
+ )} +
    + {shown.length === 0 &&
  • {labels.noOptions}
  • } + {shown.map((o, i) => { + const on = isOn(o.value) + return ( +
  • setActive(i)} onClick={() => pick(o)} + > + {multiple + ? + : null} + {o.dot &&
  • + ) + })} +
+ {multiple && chosen.length > 0 && ( +
+ +
+ )} +
+
+ )} + + ) +} diff --git a/packages/ui/src/components/InfoTip.jsx b/packages/ui/src/components/InfoTip.jsx index e3e513c..d81f6e7 100644 --- a/packages/ui/src/components/InfoTip.jsx +++ b/packages/ui/src/components/InfoTip.jsx @@ -8,8 +8,8 @@ const MARGIN = 8 /** * The "(i)" help tip next to a setting or label (D-12: every manager page gets them). - * Opens on click/tap (works on touch screens), closes on Escape, a click outside, or - * a second click. Placed above the button, or below when there's no room. + * Opens while the pointer rests on it (2026-11-20) and on click/tap (touch screens: a tap keeps + * it open), closes on Escape, a click outside, a second click or the pointer leaving. Placed above the button, or below when there's no room. * * * @@ -17,7 +17,14 @@ const MARGIN = 8 */ export function InfoTip({ children, label, side = 'top', className }) { const labels = useLabels() - const [open, setOpen] = useState(false) + const [pinned, setPinned] = useState(false) + const [hover, setHover] = useState(false) + const leaveTimer = useRef(null) + const open = pinned || hover + const setOpen = v => { setPinned(v); if (!v) setHover(false) } + const enter = () => { clearTimeout(leaveTimer.current); setHover(true) } + const leave = () => { clearTimeout(leaveTimer.current); leaveTimer.current = setTimeout(() => setHover(false), 120) } + useEffect(() => () => clearTimeout(leaveTimer.current), []) const [pos, setPos] = useState(null) const button = useRef(null) const tip = useRef(null) @@ -66,7 +73,9 @@ export function InfoTip({ children, label, side = 'top', className }) { aria-label={label ?? labels.moreInfo} aria-expanded={open} aria-describedby={open ? id : undefined} - onClick={() => setOpen(o => !o)} + onClick={() => setOpen(!pinned)} + onPointerEnter={e => { if (e.pointerType === 'mouse') enter() }} + onPointerLeave={e => { if (e.pointerType === 'mouse') leave() }} >
+ {top &&
{top}
} +
+
{children}
+
+
+ ) +} + +/** A page's title row: title, an optional line under it, actions on the right. */ +export function PageHeader({ title, subtitle, actions, info, className }) { + return ( +
+
+ {title &&

{title}{info}

} + {subtitle &&

{subtitle}

} +
+ {actions &&
{actions}
} +
+ ) +} + +/** + * A row of filters and actions over a list. Every control in it has the same height + * (size 'md' by default: , , , ,