componente · @solu30/ui-kit/input
QuantityUnitField
Campo de cantidad con selector de unidad al lado, restringible a peso, volumen o unidades sueltas.
4 sitios de import en 3 de 15 verticales — un archivo que la importa cuenta una vez, monte una instancia o veinte.
- cmp-packages
- dietaly
- luigi
El componente, montado
Cargando el espécimen…
export function NumericFieldsMatrix() {
const [deposit, setDeposit] = useState('150000')
const [tables, setTables] = useState(8)
const [guests, setGuests] = useState(186)
const [flour, setFlour] = useState<string | null>('2.5')
const [flourUnit, setFlourUnit] = useState('kg')
const [milk, setMilk] = useState<string | null>('5')
const [milkUnit, setMilkUnit] = useState('L')
return (
<Stage label="Campos numéricos · moneda, stepper editable y cantidad+unidad" tall wide>
<div className="grid w-full grid-cols-1 gap-4 sm:grid-cols-3">
<div className="flex flex-col gap-1.5">
<Label htmlFor="deposit">Depósito de reserva</Label>
<CurrencyInput id="deposit" value={deposit} onChange={setDeposit} symbol="$" locale="es-AR" />
</div>
<div className="flex flex-col gap-1.5">
<Label>Comisión de la agencia</Label>
<CurrencyInput value="45000" onChange={() => {}} symbol="US$" locale="en-US" disabled />
<span className="text-xs text-content/50">CurrencyInput no tiene error — KIT-021.</span>
</div>
<div className="flex flex-col gap-1.5">
<Label>Mesas redondas</Label>
<QuantityStepper value={tables} onChange={setTables} min={1} max={40} size="sm" />
</div>
<div className="flex flex-col gap-1.5">
<Label>Cantidad de invitados</Label>
<QuantityStepper
value={guests}
onChange={setGuests}
min={1}
max={400}
editable
inputLabel="Cantidad de invitados"
/>
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="qty-harina">Harina (heladería)</Label>
<QuantityUnitField
id="qty-harina"
value={flour}
unit={flourUnit}
family="weight"
onChange={(v, u) => {
setFlour(v)
setFlourUnit(u)
}}
/>
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="qty-leche">Leche (heladería) — sin stock</Label>
<QuantityUnitField
id="qty-leche"
value={milk}
unit={milkUnit}
family="volume"
onChange={(v, u) => {
setMilk(v)
setMilkUnit(u)
}}
disabled
/>
</div>
</div>
</Stage>
)
}De specimens/input.tsx · NumericFieldsMatrix: el espécimen del Muestrario, no un ejemplo oficial del paquete. Muestra cómo se usa la pieza de verdad, montada contra los tipos instalados —eso es lo que vale— pero no es documentación del kit.
Cómo se usa
import { QuantityUnitField } from '@solu30/ui-kit/input'Props
| Prop | Requerida | Tipo | Qué hace |
|---|---|---|---|
| value | sí | string | null | undefined | Current numeric value as string (e.g. "500", "1.5"). Pass null or undefined to render an empty field. |
| unit | sí | string | Currently selected unit string (e.g. "g", "kg", "ml", "L", "u"). Must match one of the rendered options; if not, the browser will default to the first option. |
| family | opcional | UnitFamily | null | Restricts the unit dropdown to a physical domain. "weight" → g, kg "volume" → ml, L "discrete" → u null → all units (no restriction) |
| allowedUnits | opcional | UnitOption[] | Explicit unit options. When provided, takes precedence over `family`. Use this to override the family-derived list (e.g. vertical-specific units). |
| onChange | sí | (value: string | null, unit: string) => void | Called whenever the numeric value or the unit changes. `value` is null when the field is cleared (empty string input). |
| disabled | opcional | boolean | — |
| placeholder | opcional | string | Placeholder for the numeric input. Default: "0" |
| id | opcional | string | HTML id for the numeric input (for <label htmlFor> association). |
| ariaLabel | opcional | string | aria-label for the numeric input. Default: "Cantidad" |
| size | opcional | "sm" | "md" | — |
| className | opcional | string | — |
Ejemplo del paquete
// Unrestricted (all units)
<QuantityUnitField value={qty} unit={unit} onChange={(v, u) => setState(v, u)} />
// Restricted to weight family (g / kg)
<QuantityUnitField value={qty} unit={unit} family="weight" onChange={...} />
// Explicit allowed units
<QuantityUnitField value={qty} unit={unit}
allowedUnits={[{ value: "kg", label: "kg" }]} onChange={...} />Del @example del JSDoc de @solu30/ui-kit, sin editar: son 65 de los 541 símbolos. La sangría y los renglones en blanco son los del paquete.