Files
zeekayandHanzo Dev 751ef5c778 rename the framework to @hanzo/gui and the loader to @hanzogui/loader
Both old names are owned by a different npm account (artemis-prime), so
publishing them returns 403 — which is how this surfaced: the 8.0.0 run
shipped @hanzogui/logo and @hanzogui/demos depending on [email protected], a
version that cannot be published and therefore does not exist. Those two
were uninstallable.

@hanzo/gui and @hanzogui/* are ours, so the framework now carries the name
it is imported by everywhere downstream, and the loader moves under the
scope we control.

The rewrite is limited to package references. `DEBUG?.startsWith('hanzogui')`
is a log-namespace filter and join(dir, 'hanzogui') is a path — rewriting
either would change behaviour, so both are untouched.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-30 20:23:18 -07:00

80 lines
1.8 KiB
TypeScript

import { Minus, Plus } from '@hanzogui/lucide-icons-2'
import {
Button,
Input,
type SizeTokens,
type InputProps as GuiInputProps,
} from '@hanzo/gui'
export type NumberInputProps = {
size: SizeTokens
value: number
onValueChange?: (newValue: number) => void
min?: number
max?: number
} & Omit<GuiInputProps, 'value' | 'onValueChange'>
export function NumberInput({
size,
min,
max,
value = 0,
onValueChange,
...props
}: NumberInputProps) {
const handleUpdate = (newVal: string | number) => {
const numberVal = Number(newVal)
if (Number.isNaN(numberVal)) {
return
}
if (
(typeof max !== 'undefined' && numberVal > max) ||
(typeof min !== 'undefined' && numberVal < min)
) {
return
}
onValueChange?.(numberVal)
}
const canDecrease = typeof min !== 'undefined' && value - 1 >= min
const canIncrease = typeof max !== 'undefined' && value + 1 <= max
// TODO: we manually set the border radius for now
return (
<>
<Button
disabled={!canDecrease}
variant="outlined"
size={size}
icon={Minus}
onPress={() => {
handleUpdate(value - 1)
}}
borderBottomRightRadius="$0"
borderTopRightRadius="$0"
borderWidth={0}
/>
<Input
width={50}
size={size}
value={value.toString()}
onChange={(e) => handleUpdate(e.target?.value ?? '')}
{...props}
rounded="$0"
/>
<Button
disabled={!canIncrease}
variant="outlined"
size={size}
icon={Plus}
onPress={() => {
handleUpdate(value + 1)
}}
rounded="$4"
borderLeftWidth={0}
borderTopLeftRadius="$0"
borderBottomLeftRadius="$0"
/>
</>
)
}