Move DurationInput to @probo/ui and scope pattern merge by category

Move the DurationInput component from the console app into @probo/ui
for reuse, add duration formatting helpers to @probo/helpers, and
update pattern merge to group by both category ID and prefix.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-30 10:48:49 +04:00
parent 2fe77d9ddc
commit 427bbbaf5c
8 changed files with 58 additions and 43 deletions

View File

@@ -0,0 +1,48 @@
// Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
import { DURATION_UNITS } from "@probo/helpers";
import { Input } from "./Input";
interface DurationInputProps {
value: string;
unit: string;
onValueChange: (value: string) => void;
onUnitChange: (unit: string) => void;
}
export function DurationInput({ value, unit, onValueChange, onUnitChange }: DurationInputProps) {
return (
<div className="flex gap-1">
<Input
type="number"
min={0}
value={value}
onChange={e => onValueChange(e.target.value)}
placeholder="—"
className="w-20"
/>
<select
value={unit}
onChange={e => onUnitChange(e.target.value)}
className="rounded border border-border bg-background px-2 py-1 text-sm"
>
{DURATION_UNITS.map(u => (
<option key={u.value} value={u.value}>{u.label}</option>
))}
</select>
</div>
);
}

View File

@@ -39,6 +39,7 @@ export {
export { Avatar } from "./Atoms/Avatar/Avatar";
export { Field } from "./Molecules/Field/Field";
export { Input } from "./Atoms/Input/Input";
export { DurationInput } from "./Atoms/Input/DurationInput";
export { Textarea } from "./Atoms/Textarea/Textarea";
export { Option, Select, SelectGroup, SelectLabel } from "./Atoms/Select/Select";
export { Label } from "./Atoms/Label/Label";