{"version":3,"names":["createMemo","getCombinedFieldValidityData","useFieldRootContext","FieldValidity","props","field","snapshot","combined","validityData","invalid","validity","state","errors","error","value","initialValue","children"],"sources":["field-validity.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport { createMemo } from \"solid-js\";\nimport {\n\ttype FieldValidityData,\n\ttype FieldValidityState as FieldValidityStateRaw,\n\tgetCombinedFieldValidityData,\n\tuseFieldRootContext,\n} from \"../../internals/field-context.ts\";\n\n/**\n * Snapshot passed to `<Field.Validity>`'s function child. Mirrors React's\n * `FieldValidity.State` shape — the `state` slot (inside\n * `FieldValidityData`) is re-exposed as `validity` for API clarity.\n */\nexport interface FieldValidityState extends Omit<FieldValidityData, \"state\"> {\n\t/** The raw validity state (`ValidityState`-shaped). */\n\tvalidity: FieldValidityStateRaw;\n}\n\nexport interface FieldValidityProps {\n\t/**\n\t * Function child that receives the current validity snapshot. Must be a\n\t * function — `<Field.Validity>` exists specifically to expose the snapshot\n\t * for consumer-rendered UI.\n\t *\n\t * ```tsx\n\t * <Field.Validity>\n\t *   {(validity) => validity.validity.valueMissing\n\t *     ? <span>Required</span>\n\t *     : null}\n\t * </Field.Validity>\n\t * ```\n\t */\n\tchildren: (state: FieldValidityState) => JSX.Element;\n}\n\n/**\n * Renders nothing by itself — passes the current validity snapshot to its\n * function child. Mirrors Base UI React's `<Field.Validity>`.\n *\n * Solid 2 note: the snapshot is recomputed inside a `createMemo` so the\n * function child re-evaluates only when the validity or external `invalid`\n * flag actually changes.\n */\nexport function FieldValidity(props: FieldValidityProps): JSX.Element {\n\tconst field = useFieldRootContext();\n\n\tconst snapshot = createMemo((): FieldValidityState => {\n\t\tconst combined = getCombinedFieldValidityData(\n\t\t\tfield.validityData(),\n\t\t\tfield.invalid(),\n\t\t);\n\t\treturn {\n\t\t\tvalidity: combined.state,\n\t\t\terrors: combined.errors,\n\t\t\terror: combined.error,\n\t\t\tvalue: combined.value,\n\t\t\tinitialValue: combined.initialValue,\n\t\t};\n\t});\n\n\t// Return a JSX expression that re-invokes the child as `snapshot()`\n\t// updates — Solid's compiler tracks this as a reactive dependency.\n\treturn <>{props.children(snapshot())}</>;\n}\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,UAAU;AACrC,SAGCC,4BAA4B,EAC5BC,mBAAmB,QACb,kCAAkC;;AAEzC;AACA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,KAAyB,EAAe;EACrE,MAAMC,KAAK,GAAGH,mBAAmB,CAAC,CAAC;EAEnC,MAAMI,QAAQ,GAAGN,UAAU,CAAC,MAA0B;IACrD,MAAMO,QAAQ,GAAGN,4BAA4B,CAC5CI,KAAK,CAACG,YAAY,CAAC,CAAC,EACpBH,KAAK,CAACI,OAAO,CAAC,CACf,CAAC;IACD,OAAO;MACNC,QAAQ,EAAEH,QAAQ,CAACI,KAAK;MACxBC,MAAM,EAAEL,QAAQ,CAACK,MAAM;MACvBC,KAAK,EAAEN,QAAQ,CAACM,KAAK;MACrBC,KAAK,EAAEP,QAAQ,CAACO,KAAK;MACrBC,YAAY,EAAER,QAAQ,CAACQ;IACxB,CAAC;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,EAAE,CAACX,KAAK,CAACY,QAAQ,CAACV,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG;AACzC","ignoreList":[]}