The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { useState } from "react"; |
| 2 | import { |
| 3 | DEFAULT_SNOOZE_PRESETS, |
| 4 | MAX_SNOOZE_PRESET_MINUTES, |
| 5 | MAX_SNOOZE_PRESETS, |
| 6 | SnoozePresetDay, |
| 7 | type SnoozePresetSetting, |
| 8 | } from "@t3tools/contracts/settings"; |
| 9 | import { |
| 10 | resolveSnoozePreset, |
| 11 | resolveSnoozePresets, |
| 12 | snoozePresetId, |
| 13 | } from "@t3tools/client-runtime/state/thread-settled"; |
| 14 | import * as Equal from "effect/Equal"; |
| 15 | import * as Schema from "effect/Schema"; |
| 16 | import { msg, T, useGT, useLocale, useMessages, Var } from "gt-react"; |
| 17 | import { PlusIcon, XIcon } from "lucide-react"; |
| 18 | |
| 19 | import { useNowMinute } from "../../hooks/useNowMinute"; |
| 20 | import { reconcileSnoozeDraft, sortSnoozeRows } from "./SnoozePresetsSettings.logic"; |
| 21 | import { formatShortTimestamp } from "../../timestampFormat"; |
| 22 | import { Button } from "../ui/button"; |
| 23 | import { Input } from "../ui/input"; |
| 24 | import { |
| 25 | NumberField, |
| 26 | NumberFieldDecrement, |
| 27 | NumberFieldGroup, |
| 28 | NumberFieldIncrement, |
| 29 | NumberFieldInput, |
| 30 | } from "../ui/number-field"; |
| 31 | import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select"; |
| 32 | import { SettingResetButton, SettingsRow } from "./settingsLayout"; |
| 33 | import { useSearchableSetting } from "./settingsSearch"; |
| 34 | import { |
| 35 | useScopedSettings, |
| 36 | useScopedSettingsMixed, |
| 37 | useUpdateScopedSettings, |
| 38 | } from "./useScopedSettings"; |
| 39 | |
| 40 | const UNIT_MINUTES = { minutes: 1, hours: 60, days: 24 * 60 } as const; |
| 41 | type DurationUnit = keyof typeof UNIT_MINUTES; |
| 42 | const UNIT_LABELS: Record<DurationUnit, string> = { |
| 43 | minutes: msg("{count, plural, one {minute} other {minutes}}"), |
| 44 | hours: msg("{count, plural, one {hour} other {hours}}"), |
| 45 | days: msg("{count, plural, one {day} other {days}}"), |
| 46 | }; |
| 47 | |
| 48 | const WHEN_LABELS: Record<"after" | "today" | "tomorrow", string> = { |
| 49 | after: msg("In", { $context: "snooze for a duration, as in: In 2 hours" }), |
| 50 | today: msg("Today"), |
| 51 | tomorrow: msg("Tomorrow"), |
| 52 | }; |
| 53 | // 2024-01-01 was a Monday. |
| 54 | const WEEKDAY_DATES: Record<Exclude<SnoozePresetDay, "today" | "tomorrow">, Date> = { |
| 55 | monday: new Date(Date.UTC(2024, 0, 1)), |
| 56 | tuesday: new Date(Date.UTC(2024, 0, 2)), |
| 57 | wednesday: new Date(Date.UTC(2024, 0, 3)), |
| 58 | thursday: new Date(Date.UTC(2024, 0, 4)), |
| 59 | friday: new Date(Date.UTC(2024, 0, 5)), |
| 60 | saturday: new Date(Date.UTC(2024, 0, 6)), |
| 61 | sunday: new Date(Date.UTC(2024, 0, 7)), |
| 62 | }; |
| 63 | |
| 64 | function whenLabel( |
| 65 | value: "after" | SnoozePresetDay, |
| 66 | resolve: (message: string) => string, |
| 67 | locale: string, |
| 68 | ): string { |
| 69 | if (value === "after" || value === "today" || value === "tomorrow") { |
| 70 | return resolve(WHEN_LABELS[value]); |
| 71 | } |
| 72 | const name = new Intl.DateTimeFormat(locale, { weekday: "long", timeZone: "UTC" }).format( |
| 73 | WEEKDAY_DATES[value], |
| 74 | ); |
| 75 | return name.charAt(0).toLocaleUpperCase(locale) + name.slice(1); |
| 76 | } |
| 77 | const WHEN_VALUES = ["after", ...SnoozePresetDay.literals] as const; |
| 78 | |
| 79 | // Offered in order when adding, skipping any already in the list. |
| 80 | const ADD_CANDIDATES: ReadonlyArray<SnoozePresetSetting> = [ |
| 81 | ...DEFAULT_SNOOZE_PRESETS, |
| 82 | { kind: "after", minutes: 30 }, |
| 83 | { kind: "at", day: "saturday", time: "09:00" }, |
| 84 | { kind: "after", minutes: 24 * 60 }, |
| 85 | ]; |
| 86 | |
| 87 | function splitMinutes(minutes: number): { amount: number; unit: DurationUnit } { |
| 88 | if (minutes % UNIT_MINUTES.days === 0) |
| 89 | return { amount: minutes / UNIT_MINUTES.days, unit: "days" }; |
| 90 | if (minutes % UNIT_MINUTES.hours === 0) { |
| 91 | return { amount: minutes / UNIT_MINUTES.hours, unit: "hours" }; |
| 92 | } |
| 93 | return { amount: minutes, unit: "minutes" }; |
| 94 | } |
| 95 | |
| 96 | function nextCandidate(presets: ReadonlyArray<SnoozePresetSetting>): SnoozePresetSetting { |
| 97 | const used = new Set(presets.map(snoozePresetId)); |
| 98 | return ( |
| 99 | ADD_CANDIDATES.find((candidate) => !used.has(snoozePresetId(candidate))) ?? { |
| 100 | kind: "after", |
| 101 | minutes: 60, |
| 102 | } |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | // Row order is only display order, so it does not make a list differ from the defaults. |
| 107 | function sameSnoozePresets( |
| 108 | left: ReadonlyArray<SnoozePresetSetting>, |
| 109 | right: ReadonlyArray<SnoozePresetSetting>, |
| 110 | ) { |
| 111 | const ids = (presets: ReadonlyArray<SnoozePresetSetting>) => |
| 112 | presets.map(snoozePresetId).toSorted(); |
| 113 | return Equal.equals(ids(left), ids(right)); |
| 114 | } |
| 115 | |
| 116 | const isSnoozePresetDay = Schema.is(SnoozePresetDay); |
| 117 | |
| 118 | interface KindMemory { |
| 119 | readonly minutes: number; |
| 120 | readonly time: string; |
| 121 | } |
| 122 | |
| 123 | function withWhen( |
| 124 | preset: SnoozePresetSetting, |
| 125 | when: string, |
| 126 | memory: KindMemory, |
| 127 | ): SnoozePresetSetting | null { |
| 128 | if (when === "after") { |
| 129 | return preset.kind === "after" ? preset : { kind: "after", minutes: memory.minutes }; |
| 130 | } |
| 131 | if (!isSnoozePresetDay(when)) return null; |
| 132 | return { kind: "at", day: when, time: preset.kind === "at" ? preset.time : memory.time }; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Edits the snooze menu's options. Rows sort by wake time like the menu, but only when focus |
| 137 | * leaves the list, so a row never moves under the pointer mid-edit. |
| 138 | */ |
| 139 | export function SnoozePresetsRow() { |
| 140 | const gt = useGT(); |
| 141 | const searchableSetting = useSearchableSetting(); |
| 142 | const settings = useScopedSettings(); |
| 143 | const updateSettings = useUpdateScopedSettings(); |
| 144 | const saved = settings.snoozePresets; |
| 145 | const nowMinute = useNowMinute(); |
| 146 | const now = new Date(`${nowMinute}Z`); |
| 147 | // Edits build on a local draft, so a second edit before the first save echoes back |
| 148 | // does not restore what the first one changed. Echoes of our own writes keep the draft. |
| 149 | // Row keys survive removals and sorts, so a row's in-progress field state stays with it. |
| 150 | // One state, so a sort queued in the same event as an edit applies on top of it. |
| 151 | const [rows, setRows] = useState(() => |
| 152 | sortSnoozeRows( |
| 153 | saved, |
| 154 | saved.map((_, index) => index), |
| 155 | now, |
| 156 | ), |
| 157 | ); |
| 158 | const { presets, keys } = rows; |
| 159 | const [nextKey, setNextKey] = useState(saved.length); |
| 160 | // Null forces the next render to adopt the saved value, as after a failed write. |
| 161 | const [savedSource, setSavedSource] = useState<ReadonlyArray<SnoozePresetSetting> | null>(saved); |
| 162 | // Environments disagree, so equal-looking edits and Reset must still write to all of them. |
| 163 | const mixed = useScopedSettingsMixed(["snoozePresets"]); |
| 164 | const [written, setWritten] = useState<ReadonlyArray<ReadonlyArray<SnoozePresetSetting>>>([]); |
| 165 | const freshKeys = (count: number) => { |
| 166 | setNextKey(nextKey + count); |
| 167 | return Array.from({ length: count }, (_, index) => nextKey + index); |
| 168 | }; |
| 169 | if (!Equal.equals(savedSource, saved)) { |
| 170 | setSavedSource(saved); |
| 171 | const reconciled = reconcileSnoozeDraft(written, saved); |
| 172 | if (reconciled.adopt) { |
| 173 | setWritten([]); |
| 174 | setRows(sortSnoozeRows(saved, freshKeys(saved.length), now)); |
| 175 | } else { |
| 176 | setWritten(reconciled.pending); |
| 177 | } |
| 178 | } |
| 179 | const save = ( |
| 180 | snoozePresets: ReadonlyArray<SnoozePresetSetting>, |
| 181 | nextKeys: ReadonlyArray<number> = keys, |
| 182 | ) => { |
| 183 | if (!mixed && Equal.equals(snoozePresets, presets)) return; |
| 184 | setRows({ presets: snoozePresets, keys: nextKeys }); |
| 185 | setWritten((previous) => [...previous, snoozePresets]); |
| 186 | updateSettings( |
| 187 | { snoozePresets }, |
| 188 | { |
| 189 | onFailed: () => { |
| 190 | setWritten([]); |
| 191 | setSavedSource(null); |
| 192 | }, |
| 193 | }, |
| 194 | ); |
| 195 | }; |
| 196 | const replaceAt = (index: number, next: SnoozePresetSetting) => |
| 197 | save(presets.map((preset, candidate) => (candidate === index ? next : preset))); |
| 198 | |
| 199 | return ( |
| 200 | <SettingsRow |
| 201 | serverScoped |
| 202 | settingKeys={["snoozePresets"]} |
| 203 | {...searchableSetting("snooze-options")} |
| 204 | description={gt( |
| 205 | "Choices in every snooze menu, listed soonest first. Weekdays mean the next one after today.", |
| 206 | )} |
| 207 | resetAction={ |
| 208 | !mixed && sameSnoozePresets(presets, DEFAULT_SNOOZE_PRESETS) ? null : ( |
| 209 | <SettingResetButton |
| 210 | ariaLabel={gt("Reset snooze options to default")} |
| 211 | onClick={() => { |
| 212 | const sorted = sortSnoozeRows( |
| 213 | DEFAULT_SNOOZE_PRESETS, |
| 214 | freshKeys(DEFAULT_SNOOZE_PRESETS.length), |
| 215 | now, |
| 216 | ); |
| 217 | save(sorted.presets, sorted.keys); |
| 218 | }} |
| 219 | /> |
| 220 | ) |
| 221 | } |
| 222 | > |
| 223 | <SnoozePresetList |
| 224 | presets={presets} |
| 225 | keys={keys} |
| 226 | timestampFormat={settings.timestampFormat} |
| 227 | onChange={replaceAt} |
| 228 | onRemove={(index) => |
| 229 | save( |
| 230 | presets.filter((_, candidate) => candidate !== index), |
| 231 | keys.filter((_, candidate) => candidate !== index), |
| 232 | ) |
| 233 | } |
| 234 | onAdd={() => save([...presets, nextCandidate(presets)], [...keys, ...freshKeys(1)])} |
| 235 | onSettle={() => setRows((current) => sortSnoozeRows(current.presets, current.keys, now))} |
| 236 | /> |
| 237 | </SettingsRow> |
| 238 | ); |
| 239 | } |
| 240 | |
| 241 | function SnoozePresetList(props: { |
| 242 | presets: ReadonlyArray<SnoozePresetSetting>; |
| 243 | keys: ReadonlyArray<number>; |
| 244 | timestampFormat: Parameters<typeof formatShortTimestamp>[1]; |
| 245 | onChange: (index: number, preset: SnoozePresetSetting) => void; |
| 246 | onRemove: (index: number) => void; |
| 247 | onAdd: () => void; |
| 248 | onSettle: () => void; |
| 249 | }) { |
| 250 | const gt = useGT(); |
| 251 | const m = useMessages(); |
| 252 | const nowMinute = useNowMinute(); |
| 253 | const now = new Date(`${nowMinute}Z`); |
| 254 | const formatTime = (date: Date) => |
| 255 | formatShortTimestamp(date.toISOString(), props.timestampFormat); |
| 256 | const seenIds = new Set<string>(); |
| 257 | const seenWakes = new Set<string>(); |
| 258 | const previews = props.presets.map((preset) => { |
| 259 | const resolved = resolveSnoozePreset(preset, now, formatTime, m); |
| 260 | if (resolved === null) return { tone: "muted", text: gt("Passed for today") } as const; |
| 261 | if (seenIds.has(resolved.id)) { |
| 262 | return { tone: "muted", text: gt("Duplicate of an option above") } as const; |
| 263 | } |
| 264 | if (seenWakes.has(resolved.snoozedUntil)) { |
| 265 | return { tone: "muted", text: gt("Same time as an option above") } as const; |
| 266 | } |
| 267 | seenIds.add(resolved.id); |
| 268 | seenWakes.add(resolved.snoozedUntil); |
| 269 | return { tone: "menu", label: resolved.label, when: resolved.whenLabel } as const; |
| 270 | }); |
| 271 | |
| 272 | const menuPresets = resolveSnoozePresets(now, { presets: props.presets, formatTime }, m); |
| 273 | const repeatedLabels = new Set( |
| 274 | menuPresets |
| 275 | .map((preset) => preset.label) |
| 276 | .filter((label, index, labels) => labels.indexOf(label) !== index), |
| 277 | ); |
| 278 | const menuOrder = menuPresets.map((preset) => |
| 279 | repeatedLabels.has(preset.label) ? `${preset.label} ${preset.whenLabel}` : preset.label, |
| 280 | ); |
| 281 | |
| 282 | return ( |
| 283 | <div |
| 284 | className="flex flex-col gap-1.5 pt-3 pb-2" |
| 285 | onBlur={(event) => { |
| 286 | const list = event.currentTarget; |
| 287 | const next = event.relatedTarget; |
| 288 | if (list.contains(next)) return; |
| 289 | // Select popups portal out of the list, so focus moving into one is not leaving it. |
| 290 | if (next instanceof Element && next.closest('[data-slot="select-popup"]')) return; |
| 291 | // Waits for the amount field's blur commit, and skips its Enter blur-and-refocus. |
| 292 | queueMicrotask(() => { |
| 293 | if (!list.contains(document.activeElement)) props.onSettle(); |
| 294 | }); |
| 295 | }} |
| 296 | > |
| 297 | {props.presets.map((preset, index) => { |
| 298 | const preview = previews[index]!; |
| 299 | return ( |
| 300 | <div |
| 301 | key={props.keys[index]} |
| 302 | role="group" |
| 303 | aria-label={gt("Snooze option {number}", { number: index + 1 })} |
| 304 | className="flex flex-wrap items-center gap-2" |
| 305 | > |
| 306 | <SnoozePresetFields preset={preset} onChange={(next) => props.onChange(index, next)} /> |
| 307 | <div className="ml-auto flex min-w-0 items-center gap-2 text-xs text-muted-foreground"> |
| 308 | {preview.tone === "menu" ? ( |
| 309 | <span className="truncate"> |
| 310 | <span className="text-foreground">{preview.label}</span> |
| 311 | <span className="ps-2 tabular-nums">{preview.when}</span> |
| 312 | </span> |
| 313 | ) : ( |
| 314 | <span className="truncate">{preview.text}</span> |
| 315 | )} |
| 316 | <Button |
| 317 | variant="ghost-muted" |
| 318 | size="icon-sm" |
| 319 | aria-label={gt("Remove snooze option {number}", { number: index + 1 })} |
| 320 | onClick={() => props.onRemove(index)} |
| 321 | > |
| 322 | <XIcon /> |
| 323 | </Button> |
| 324 | </div> |
| 325 | </div> |
| 326 | ); |
| 327 | })} |
| 328 | <p className="text-xs text-muted-foreground"> |
| 329 | {menuOrder.length === 0 |
| 330 | ? gt("Menus offer only Custom…") |
| 331 | : gt("Menu now: {options}", { options: menuOrder.join(" · ") })} |
| 332 | </p> |
| 333 | <div> |
| 334 | <Button |
| 335 | variant="ghost-muted" |
| 336 | size="compact" |
| 337 | // Not `disabled`: that drops focus, which the list would read as leaving it and sort. |
| 338 | aria-disabled={props.presets.length >= MAX_SNOOZE_PRESETS || undefined} |
| 339 | onClick={props.presets.length >= MAX_SNOOZE_PRESETS ? undefined : props.onAdd} |
| 340 | > |
| 341 | <PlusIcon /> |
| 342 | <T>Add option</T> |
| 343 | </Button> |
| 344 | {props.presets.length >= MAX_SNOOZE_PRESETS ? ( |
| 345 | <span className="ps-2 text-xs text-muted-foreground"> |
| 346 | <T> |
| 347 | Up to <Var>{MAX_SNOOZE_PRESETS}</Var> options |
| 348 | </T> |
| 349 | </span> |
| 350 | ) : null} |
| 351 | </div> |
| 352 | </div> |
| 353 | ); |
| 354 | } |
| 355 | |
| 356 | function SnoozePresetFields(props: { |
| 357 | preset: SnoozePresetSetting; |
| 358 | onChange: (preset: SnoozePresetSetting) => void; |
| 359 | }) { |
| 360 | const gt = useGT(); |
| 361 | const m = useMessages(); |
| 362 | const locale = useLocale(); |
| 363 | const { preset, onChange } = props; |
| 364 | const when = preset.kind === "after" ? "after" : preset.day; |
| 365 | // Switching between a duration and a set time keeps the other kind's last value, so a |
| 366 | // misclick on "When" can be undone without retyping it. |
| 367 | const [memory, setMemory] = useState<KindMemory>({ minutes: 60, time: "09:00" }); |
| 368 | return ( |
| 369 | <div className="flex min-w-0 flex-wrap items-center gap-2"> |
| 370 | <Select |
| 371 | value={when} |
| 372 | items={Object.fromEntries(WHEN_VALUES.map((value) => [value, whenLabel(value, m, locale)]))} |
| 373 | onValueChange={(value) => { |
| 374 | const next = value === null ? null : withWhen(preset, value, memory); |
| 375 | if (!next) return; |
| 376 | if (next.kind !== preset.kind) { |
| 377 | setMemory( |
| 378 | preset.kind === "after" |
| 379 | ? { ...memory, minutes: preset.minutes } |
| 380 | : { ...memory, time: preset.time }, |
| 381 | ); |
| 382 | } |
| 383 | onChange(next); |
| 384 | }} |
| 385 | > |
| 386 | <SelectTrigger size="sm" className="w-32" aria-label={gt("When")}> |
| 387 | <SelectValue /> |
| 388 | </SelectTrigger> |
| 389 | <SelectPopup> |
| 390 | {WHEN_VALUES.map((value) => ( |
| 391 | <SelectItem hideIndicator key={value} value={value}> |
| 392 | {whenLabel(value, m, locale)} |
| 393 | </SelectItem> |
| 394 | ))} |
| 395 | </SelectPopup> |
| 396 | </Select> |
| 397 | {preset.kind === "after" ? ( |
| 398 | <DurationFields |
| 399 | minutes={preset.minutes} |
| 400 | onChange={(minutes) => onChange({ ...preset, minutes })} |
| 401 | /> |
| 402 | ) : ( |
| 403 | <div className="flex min-w-0 flex-wrap items-center gap-2"> |
| 404 | <span className="text-xs text-muted-foreground"> |
| 405 | {gt("at", { $context: "before a time of day, as in: Monday at 09:00" })} |
| 406 | </span> |
| 407 | <Input |
| 408 | nativeInput |
| 409 | size="sm" |
| 410 | type="time" |
| 411 | className="w-32" |
| 412 | aria-label={gt("Time", { $context: "time of day" })} |
| 413 | value={preset.time} |
| 414 | onChange={(event) => { |
| 415 | if (/^\d{2}:\d{2}$/.test(event.target.value)) { |
| 416 | onChange({ ...preset, time: event.target.value }); |
| 417 | } |
| 418 | }} |
| 419 | /> |
| 420 | </div> |
| 421 | )} |
| 422 | </div> |
| 423 | ); |
| 424 | } |
| 425 | |
| 426 | function DurationFields(props: { minutes: number; onChange: (minutes: number) => void }) { |
| 427 | const gt = useGT(); |
| 428 | const m = useMessages(); |
| 429 | // The chosen unit stays put while stepping, so 59 → 60 minutes does not jump to hours. |
| 430 | const [chosenUnit, setChosenUnit] = useState(() => splitMinutes(props.minutes).unit); |
| 431 | const unit = |
| 432 | props.minutes % UNIT_MINUTES[chosenUnit] === 0 ? chosenUnit : splitMinutes(props.minutes).unit; |
| 433 | const amount = props.minutes / UNIT_MINUTES[unit]; |
| 434 | const maxAmount = Math.floor(MAX_SNOOZE_PRESET_MINUTES / UNIT_MINUTES[unit]); |
| 435 | // Typing stays local until the field commits (blur, Enter, or a step), so half-typed |
| 436 | // values never reach the server. |
| 437 | const [draft, setDraft] = useState<number | null>(amount); |
| 438 | const [draftSource, setDraftSource] = useState(`${props.minutes}:${unit}`); |
| 439 | if (draftSource !== `${props.minutes}:${unit}`) { |
| 440 | setDraftSource(`${props.minutes}:${unit}`); |
| 441 | setDraft(amount); |
| 442 | } |
| 443 | return ( |
| 444 | <div className="flex min-w-0 flex-wrap items-center gap-2"> |
| 445 | <NumberField |
| 446 | size="sm" |
| 447 | className="w-32" |
| 448 | min={1} |
| 449 | max={maxAmount} |
| 450 | step={1} |
| 451 | value={draft} |
| 452 | onValueChange={setDraft} |
| 453 | onValueCommitted={(value) => { |
| 454 | if (value === null) { |
| 455 | setDraft(amount); |
| 456 | return; |
| 457 | } |
| 458 | const next = Math.min(maxAmount, Math.max(1, Math.round(value))); |
| 459 | setDraft(next); |
| 460 | if (next !== amount) props.onChange(next * UNIT_MINUTES[unit]); |
| 461 | }} |
| 462 | > |
| 463 | <NumberFieldGroup> |
| 464 | <NumberFieldDecrement aria-label={gt("Decrease")} /> |
| 465 | <NumberFieldInput |
| 466 | aria-label={gt("Amount")} |
| 467 | // Base UI commits on blur but not on Enter; refocus so keyboard users stay put. |
| 468 | onKeyDown={(event) => { |
| 469 | if (event.key !== "Enter") return; |
| 470 | const input = event.currentTarget; |
| 471 | input.blur(); |
| 472 | input.focus(); |
| 473 | }} |
| 474 | /> |
| 475 | <NumberFieldIncrement aria-label={gt("Increase")} /> |
| 476 | </NumberFieldGroup> |
| 477 | </NumberField> |
| 478 | <Select |
| 479 | value={unit} |
| 480 | items={Object.fromEntries( |
| 481 | (Object.keys(UNIT_LABELS) as DurationUnit[]).map((value) => [ |
| 482 | value, |
| 483 | m(UNIT_LABELS[value], { count: amount }), |
| 484 | ]), |
| 485 | )} |
| 486 | onValueChange={(value) => { |
| 487 | if (value === "minutes" || value === "hours" || value === "days") { |
| 488 | setChosenUnit(value); |
| 489 | props.onChange(Math.min(amount * UNIT_MINUTES[value], MAX_SNOOZE_PRESET_MINUTES)); |
| 490 | } |
| 491 | }} |
| 492 | > |
| 493 | <SelectTrigger |
| 494 | size="sm" |
| 495 | className="w-28" |
| 496 | aria-label={gt("Unit", { $context: "unit of time" })} |
| 497 | > |
| 498 | <SelectValue /> |
| 499 | </SelectTrigger> |
| 500 | <SelectPopup> |
| 501 | {(Object.keys(UNIT_LABELS) as DurationUnit[]).map((value) => ( |
| 502 | <SelectItem hideIndicator key={value} value={value}> |
| 503 | {m(UNIT_LABELS[value], { count: amount })} |
| 504 | </SelectItem> |
| 505 | ))} |
| 506 | </SelectPopup> |
| 507 | </Select> |
| 508 | </div> |
| 509 | ); |
| 510 | } |