{"version":3,"names":["createContext","useContext","NumberFieldRootContext","useNumberFieldRootContext","context","Error"],"sources":["number-field-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tBaseUIGenericEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\nimport type {\n\tChangeEventCustomProperties,\n\tEventWithOptionalKeyState,\n\tIncrementValueParameters,\n} from \"../utils/types.ts\";\nimport type { NumberFieldRootState } from \"./number-field-root.tsx\";\n\nexport type InputMode = \"numeric\" | \"decimal\" | \"text\";\n\nexport type NumberFieldRootChangeEventReason =\n\t| typeof REASONS.inputChange\n\t| typeof REASONS.inputClear\n\t| typeof REASONS.inputBlur\n\t| typeof REASONS.inputPaste\n\t| typeof REASONS.keyboard\n\t| typeof REASONS.incrementPress\n\t| typeof REASONS.decrementPress\n\t| typeof REASONS.wheel\n\t| typeof REASONS.scrub\n\t| typeof REASONS.none;\n\nexport type NumberFieldRootChangeEventDetails = BaseUIChangeEventDetails<\n\tNumberFieldRootChangeEventReason,\n\tChangeEventCustomProperties\n>;\n\nexport type NumberFieldRootCommitEventReason =\n\t| typeof REASONS.inputBlur\n\t| typeof REASONS.inputClear\n\t| typeof REASONS.keyboard\n\t| typeof REASONS.incrementPress\n\t| typeof REASONS.decrementPress\n\t| typeof REASONS.wheel\n\t| typeof REASONS.scrub\n\t| typeof REASONS.none;\n\nexport type NumberFieldRootCommitEventDetails =\n\tBaseUIGenericEventDetails<NumberFieldRootCommitEventReason>;\n\n/**\n * Root context shared across every `<NumberField.*>` part. Every reactive\n * entry is exposed as an `Accessor<T>` so descendants can subscribe to the\n * pieces they care about without rereading the entire bag.\n *\n * Non-reactive slots (`inputRef`, `valueRef`, `hasPendingCommitRef`) are\n * plain mutable records — shared between root / input / buttons so each\n * part can read the latest committed state synchronously from event\n * handlers.\n */\nexport interface NumberFieldRootContextValue {\n\tinputRef: { current: HTMLInputElement | null };\n\tinputValue: Accessor<string>;\n\tvalue: Accessor<number | null>;\n\tminWithDefault: Accessor<number>;\n\tmaxWithDefault: Accessor<number>;\n\tdisabled: Accessor<boolean>;\n\treadOnly: Accessor<boolean>;\n\tid: string;\n\tsetValue: (\n\t\tvalue: number | null,\n\t\tdetails: NumberFieldRootChangeEventDetails,\n\t) => boolean;\n\tgetStepAmount: (event?: EventWithOptionalKeyState) => number | undefined;\n\tincrementValue: (amount: number, params: IncrementValueParameters) => boolean;\n\tallowInputSyncRef: { current: boolean };\n\tformatOptionsRef: { current: Intl.NumberFormatOptions | undefined };\n\tvalueRef: { current: number | null };\n\tlastChangedValueRef: { current: number | null };\n\thasPendingCommitRef: { current: boolean };\n\tname: Accessor<string | undefined>;\n\trequired: Accessor<boolean>;\n\tinvalid: Accessor<boolean>;\n\tinputMode: Accessor<InputMode>;\n\tgetAllowedNonNumericKeys: () => Set<string | undefined>;\n\tmin: Accessor<number | undefined>;\n\tmax: Accessor<number | undefined>;\n\tsetInputValue: (next: string) => void;\n\tlocale: Accessor<Intl.LocalesArgument | undefined>;\n\tisScrubbing: Accessor<boolean>;\n\tsetIsScrubbing: (next: boolean) => void;\n\tstate: Accessor<NumberFieldRootState>;\n\tonValueCommitted: (\n\t\tvalue: number | null,\n\t\teventDetails: NumberFieldRootCommitEventDetails,\n\t) => void;\n}\n\n/**\n * `createContext<T | null>(null)` + `== null` sentinel —\n * Solid 2's `useContext` throws `ContextNotFoundError` when the default is\n * `undefined`, which would shadow the intended Base UI error message below.\n */\nexport const NumberFieldRootContext =\n\tcreateContext<NumberFieldRootContextValue | null>(null);\n\nexport function useNumberFieldRootContext(): NumberFieldRootContextValue {\n\tconst context = useContext(NumberFieldRootContext);\n\tif (context == null) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: NumberFieldRootContext is missing. NumberField parts must be placed within <NumberField.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AA6CnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAClCF,aAAa,CAAqC,IAAI,CAAC;AAExD,OAAO,SAASG,yBAAyBA,CAAA,EAAgC;EACxE,MAAMC,OAAO,GAAGH,UAAU,CAACC,sBAAsB,CAAC;EAClD,IAAIE,OAAO,IAAI,IAAI,EAAE;IACpB,MAAM,IAAIC,KAAK,CACd,yGACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}