Saltar al contenido
El Muestrario

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…

Cómo se usa

import { QuantityUnitField } from '@solu30/ui-kit/input'

Props

11 props declaradas en los tipos de la versión instalada.
PropRequeridaTipoQué hace
valuesístring | null | undefinedCurrent numeric value as string (e.g. "500", "1.5"). Pass null or undefined to render an empty field.
unitsístringCurrently 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.
familyopcionalUnitFamily | nullRestricts the unit dropdown to a physical domain. "weight" → g, kg "volume" → ml, L "discrete" → u null → all units (no restriction)
allowedUnitsopcionalUnitOption[]Explicit unit options. When provided, takes precedence over `family`. Use this to override the family-derived list (e.g. vertical-specific units).
onChangesí(value: string | null, unit: string) => voidCalled whenever the numeric value or the unit changes. `value` is null when the field is cleared (empty string input).
disabledopcionalboolean—
placeholderopcionalstringPlaceholder for the numeric input. Default: "0"
idopcionalstringHTML id for the numeric input (for <label htmlFor> association).
ariaLabelopcionalstringaria-label for the numeric input. Default: "Cantidad"
sizeopcional"sm" | "md"—
classNameopcionalstring—

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.