Number Selector
The Number selector provides a numeric input field with optional constraints.
Options
All number selectors accept these common metadata options:
default?: number- Default value for the fielddescription?: string- Human-readable description shown in the UIrequired?: boolean- Whether the field must be provided
Number-specific options (from ServiceListSelector["number"]):
min?: number- Minimum allowed valuemax?: number- Maximum allowed valuestep?: number | "any"- Step size for increment/decrement controls, or"any"for no stepunit_of_measurement?: string- Unit to display (e.g., "s", "°C", "%")mode?: "box" | "slider"- Input mode: "box" for text input or "slider" for slider controltranslation_key?: string- Translation key for the number field
Return Type
The return type is always number (not an array, even with multiple).
Example
import { TServiceParams } from "@digital-alchemy/core";
import { ServiceField } from "@digital-alchemy/synapse";
export function SynapseServiceCreate({
synapse,
context,
logger,
}: TServiceParams) {
synapse.service.create(
{
context,
description: "Set temperature with constraints",
fields: {
// Number selector with min/max bounds and unit
temperature: ServiceField.Number({
default: 20,
description: "Target temperature",
min: 0,
max: 100,
step: 0.5,
unit_of_measurement: "°C",
required: true,
}),
},
},
async data => {
// data.temperature is typed as: number
logger.info(`Setting temperature to ${data.temperature}°C`);
}
);
}