{"version":3,"names":["createContext","useContext","createDefaultValidityData","DEFAULT_FIELD_ROOT_STATE","DEFAULT_FIELD_STATE_ATTRIBUTES","DEFAULT_VALIDITY_STATE","getCombinedFieldValidityData","NOOP","NOOP_VALIDATION","getValidationProps","props","getInputValidationProps","inputRef","current","commit","NOOP_FIELD_CONTEXT","invalid","name","undefined","disabled","validityData","setValidityData","touched","setTouched","dirty","setDirty","filled","setFilled","focused","setFocused","state","validate","validationMode","validationDebounceTime","shouldValidateOnChange","markedDirtyRef","registerFieldControl","validation","present","FieldContext","useFieldRootContext"],"sources":["field-context.ts"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport { type Accessor, createContext, useContext } from \"solid-js\";\nimport {\n\tcreateDefaultValidityData,\n\tDEFAULT_FIELD_ROOT_STATE,\n\tDEFAULT_FIELD_STATE_ATTRIBUTES,\n\ttype FieldRootState,\n\ttype FieldValidationMode,\n\ttype FieldValidityData,\n} from \"./field-constants\";\n\n// Re-export the shapes callers traditionally imported from this module so\n// we don't break any existing barrel consumers.\nexport type {\n\tFieldRootState,\n\tFieldValidationMode,\n\tFieldValidityData,\n\tFieldValidityState,\n} from \"./field-constants\";\nexport {\n\tcreateDefaultValidityData,\n\tDEFAULT_FIELD_ROOT_STATE,\n\tDEFAULT_FIELD_STATE_ATTRIBUTES,\n\tDEFAULT_VALIDITY_STATE,\n\tgetCombinedFieldValidityData,\n} from \"./field-constants\";\n\n/**\n * Validate function signature exposed by `<Field.Root validate>`. Mirrors\n * React: the consumer receives the current value plus a snapshot of every\n * sibling field's value (keyed by field name) and returns a string / list\n * of strings / `null` synchronously, or a Promise resolving to the same.\n */\nexport type FieldValidateFn = (\n\tvalue: unknown,\n\tformValues: Record<string, unknown>,\n) => string | string[] | null | Promise<string | string[] | null>;\n\n/**\n * Registration payload a control pushes into `<Field.Root>`. Mirrors React's\n * `FieldControlRegistration`.\n */\nexport interface FieldRegistration {\n\t/**\n\t * Control DOM ref. The `<Field.Root>` uses this for imperative work on\n\t * submit (focus, scroll-into-view, etc). Plain ref object — identity is\n\t * stable across the control's lifetime.\n\t */\n\tcontrolRef: { current: HTMLElement | null };\n\t/** Explicit getter, if the control needs to derive its current value. */\n\tgetValue?: (() => unknown) | undefined;\n\t/** Identifier the parent `<Form>` uses to key this field in its map. */\n\tid: string | undefined;\n\t/** Last-known value (used when `getValue` is absent). */\n\tvalue: unknown;\n}\n\n/**\n * Mutable-by-design ref the field root uses to track whether the user has\n * interacted with the control (typed, cleared, etc). Exposed so validation\n * code can suppress \"required\" errors until the user has actually touched\n * the field — see `useFieldValidation.getState()`. Plain mutable object; do\n * NOT put a signal in here.\n */\nexport interface MutableRef<T> {\n\tcurrent: T;\n}\n\n/**\n * Props-factory return shape produced by `useFieldValidation`. Consumers\n * splat these onto their element (the root element + the native input).\n *\n * Kept as a plain object-builder rather than a reactive memo because Solid\n * already tracks the individual accessors the builders read from.\n */\nexport interface FieldValidationProps {\n\t/**\n\t * Adds a11y hooks (`aria-describedby` from description, `aria-invalid`\n\t * once validity is known). Call inside a `get prop()` getter or reactive\n\t * scope if the consumer wants live updates.\n\t */\n\tgetValidationProps: (\n\t\texternalProps?: JSX.HTMLAttributes<HTMLElement>,\n\t) => JSX.HTMLAttributes<HTMLElement>;\n\t/**\n\t * Same as {@link FieldValidationProps.getValidationProps}, plus an\n\t * `onInput`-equivalent that commits the value to the validity pipeline.\n\t */\n\tgetInputValidationProps: (\n\t\texternalProps?: JSX.InputHTMLAttributes<HTMLInputElement>,\n\t) => JSX.InputHTMLAttributes<HTMLInputElement>;\n\t/** Native input ref captured by the validation pipeline. */\n\tinputRef: MutableRef<HTMLInputElement | null>;\n\t/**\n\t * Imperatively run validation against `value`. `revalidate` short-circuits\n\t * to \"only revalidate if currently invalid\" — see React's\n\t * `useFieldValidation.commit` for the full matrix.\n\t */\n\tcommit: (value: unknown, revalidate?: boolean) => Promise<void>;\n}\n\n/**\n * The value handed down by `<Field.Root>` to its children.\n *\n * Every reactive entry is an `Accessor<T>` so that consumers pull the latest\n * value on demand and don't need to worry about top-level reactive reads.\n * Setters are plain functions (most of them wrapped through\n * `createStableCallback` so they're safe to capture in refs/closures).\n *\n * When `<Field.Root>` is absent, consumers receive {@link NOOP_FIELD_CONTEXT}\n * which behaves like \"no field\" — accessors return defaults, setters do\n * nothing.\n */\nexport interface FieldContextValue {\n\tinvalid: Accessor<boolean>;\n\tname: Accessor<string | undefined>;\n\tdisabled: Accessor<boolean>;\n\tvalidityData: Accessor<FieldValidityData>;\n\tsetValidityData: (next: FieldValidityData) => void;\n\ttouched: Accessor<boolean>;\n\tsetTouched: (next: boolean) => void;\n\tdirty: Accessor<boolean>;\n\tsetDirty: (next: boolean) => void;\n\tfilled: Accessor<boolean>;\n\tsetFilled: (next: boolean) => void;\n\tfocused: Accessor<boolean>;\n\tsetFocused: (next: boolean) => void;\n\tstate: Accessor<FieldRootState>;\n\tvalidate: Accessor<FieldValidateFn | undefined>;\n\tvalidationMode: Accessor<FieldValidationMode>;\n\tvalidationDebounceTime: Accessor<number>;\n\tshouldValidateOnChange: Accessor<boolean>;\n\t/**\n\t * Mutable latch flipped to `true` the first time the user meaningfully\n\t * touches the field. Consumed by `useFieldValidation` to gate\n\t * \"valueMissing\"-only errors.\n\t */\n\tmarkedDirtyRef: MutableRef<boolean>;\n\t/**\n\t * Register (or unregister, via `registration === undefined`) a control.\n\t * The `source` symbol is created once per control setup and used to\n\t * detect stale unregistrations.\n\t */\n\tregisterFieldControl: (\n\t\tsource: symbol,\n\t\tregistration: FieldRegistration | undefined,\n\t) => void;\n\t/** Props-factories + `inputRef` + `commit` from the validation pipeline. */\n\tvalidation: FieldValidationProps;\n\t/** Marker — `true` when this context was provided by a real `<Field.Root>`. */\n\treadonly present: boolean;\n}\n\nconst NOOP = () => {};\nconst NOOP_VALIDATION: FieldValidationProps = {\n\tgetValidationProps: (props = {}) => props,\n\tgetInputValidationProps: (props = {}) => props,\n\tinputRef: { current: null },\n\tcommit: async () => {\n\t\t// Intentional no-op — without a real field root there's no validity\n\t\t// signal to commit into.\n\t},\n};\n\nexport const NOOP_FIELD_CONTEXT: FieldContextValue = {\n\tinvalid: () => false,\n\tname: () => undefined,\n\tdisabled: () => false,\n\tvalidityData: () => createDefaultValidityData(),\n\tsetValidityData: NOOP,\n\ttouched: () => DEFAULT_FIELD_STATE_ATTRIBUTES.touched,\n\tsetTouched: NOOP,\n\tdirty: () => DEFAULT_FIELD_STATE_ATTRIBUTES.dirty,\n\tsetDirty: NOOP,\n\tfilled: () => DEFAULT_FIELD_STATE_ATTRIBUTES.filled,\n\tsetFilled: NOOP,\n\tfocused: () => DEFAULT_FIELD_STATE_ATTRIBUTES.focused,\n\tsetFocused: NOOP,\n\tstate: () => DEFAULT_FIELD_ROOT_STATE,\n\tvalidate: () => undefined,\n\tvalidationMode: () => \"onSubmit\",\n\tvalidationDebounceTime: () => 0,\n\tshouldValidateOnChange: () => false,\n\tmarkedDirtyRef: { current: false },\n\tregisterFieldControl: NOOP,\n\tvalidation: NOOP_VALIDATION,\n\tpresent: false,\n};\n\n/**\n * Context carrying the field-root state. Use `<FieldContext value={...}>` to\n * provide it (Solid 2's context-as-provider pattern).\n */\nexport const FieldContext =\n\tcreateContext<FieldContextValue>(NOOP_FIELD_CONTEXT);\n\n/**\n * Read the current `<Field.Root>` context. Returns the noop context when the\n * component is not wrapped in a field — callers can branch on `.present`.\n *\n * Named after React's `useFieldRootContext`.\n */\nexport function useFieldRootContext(): FieldContextValue {\n\treturn useContext(FieldContext);\n}\n"],"mappings":"AACA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;AACnE,SACCC,yBAAyB,EACzBC,wBAAwB,EACxBC,8BAA8B,QAIxB,mBAAmB;;AAE1B;AACA;;AAOA,SACCF,yBAAyB,EACzBC,wBAAwB,EACxBC,8BAA8B,EAC9BC,sBAAsB,EACtBC,4BAA4B,QACtB,mBAAmB;;AAE1B;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAgBA;AACA;AAC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