{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAQM,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAA2B;AAoBjE,MAAM,0DAAa,CAAA,GAAA,iBAAS,EAAE,SAAS,WAAW,KAAsB,EAAE,GAA8B;IAC7G,IAAI,aAAa,CAAA,GAAA,iBAAS,EAAE;IAC5B,IAAI,CAAC,YAAY,WACf,OAAO;IAGT,qBAAO,gCAAC;QAAiB,GAAG,KAAK;QAAE,KAAK;;AAC1C;AAEA,MAAM,sDAAkB,CAAA,GAAA,iBAAS,EAAE,CAAC,OAAwB;IAC1D,IAAI,aAAa,CAAA,GAAA,iBAAS,EAAE;IAC5B,IAAI,eAAC,WAAW,EAAE,GAAG,WAAU,GAAG;IAClC,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,WAAW;QAAC,QAAQ;IAAI;IACtD,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,SAAS;QACZ,kBAAkB;QAClB,iBAAiB,WAAW,gBAAgB,CAAC,MAAM,KAAK,IAAI,YAAY,WAAW,gBAAgB,CAAC,IAAI,CAAC;QACzG,QAAQ;IACV;IAEA,IAAI,YAAY,QAAQ,IAAI,MAC1B,OAAO;IAGT,qBAAO,gCAAC,CAAA,GAAA,yCAAG;QAAE,MAAK;QAAe,aAAa;QAAc,GAAG,QAAQ;QAAG,GAAG,WAAW;QAAE,KAAK;;AACjG","sources":["packages/react-aria-components/src/FieldError.tsx"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ClassNameOrFunction, RenderProps, useRenderProps} from './utils';\nimport {DOMProps, GlobalDOMAttributes, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\nimport {Text} from './Text';\n\nexport const FieldErrorContext = createContext<ValidationResult | null>(null);\n\nexport interface FieldErrorRenderProps extends ValidationResult {}\nexport interface FieldErrorProps extends RenderProps<FieldErrorRenderProps>, DOMProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-FieldError'\n   */\n  className?: ClassNameOrFunction<FieldErrorRenderProps>,\n  /**\n   * The HTML element type to render. Defaults to `'span'`.\n   * Set to `'div'` when using block-level children (e.g. `<ul>`) to avoid invalid HTML.\n   * @default 'span'\n   */\n  elementType?: string\n}\n\n/**\n * A FieldError displays validation errors for a form field.\n */\nexport const FieldError = forwardRef(function FieldError(props: FieldErrorProps, ref: ForwardedRef<HTMLElement>) {\n  let validation = useContext(FieldErrorContext);\n  if (!validation?.isInvalid) {\n    return null;\n  }\n\n  return <FieldErrorInner {...props} ref={ref} />;\n});\n\nconst FieldErrorInner = forwardRef((props: FieldErrorProps, ref: ForwardedRef<HTMLElement>) => {\n  let validation = useContext(FieldErrorContext)!;\n  let {elementType, ...restProps} = props;\n  let domProps = filterDOMProps(restProps, {global: true})!;\n  let renderProps = useRenderProps({\n    ...restProps,\n    defaultClassName: 'react-aria-FieldError',\n    defaultChildren: validation.validationErrors.length === 0 ? undefined : validation.validationErrors.join(' '),\n    values: validation\n  });\n\n  if (renderProps.children == null) {\n    return null;\n  }\n\n  return <Text slot=\"errorMessage\" elementType={elementType} {...domProps} {...renderProps} ref={ref} />;\n});\n"],"names":[],"version":3,"file":"FieldError.mjs.map"}