import { type Accessor, type JSX, Setter, createContext, useContext, } from "solid-js"; import type { SpinButtonIntlTranslations } from "../spin-button/spin-button.intl"; export interface NumberFieldContextValue { value: Accessor; setValue: (value: number | string) => void; rawValue: Accessor; generateId: (part: string) => string; formatNumber: (number: number) => string; format: () => void; onInput: JSX.EventHandlerUnion; textValue: Accessor; minValue: Accessor; maxValue: Accessor; step: Accessor; largeStep: Accessor; changeOnWheel: Accessor; translations: Accessor; inputRef: Accessor; setInputRef: (el: HTMLInputElement) => void; hiddenInputRef: Accessor; setHiddenInputRef: (el: HTMLInputElement) => void; varyValue: (offset: number) => void; } export const NumberFieldContext = createContext(); export function useNumberFieldContext() { const context = useContext(NumberFieldContext); if (context === undefined) { throw new Error( "[kobalte]: `useNumberFieldContext` must be used within a `NumberField` component", ); } return context; }