{"ast":null,"code":"import { useSlotId as $5Odon$useSlotId, mergeProps as $5Odon$mergeProps, useId as $5Odon$useId, useLabels as $5Odon$useLabels } from \"@react-aria/utils\";\n\nfunction $parcel$export(e, n, v, s) {\n  Object.defineProperty(e, n, {\n    get: v,\n    set: s,\n    enumerable: true,\n    configurable: true\n  });\n}\n\nvar $c796961545123cf9$exports = {};\n$parcel$export($c796961545123cf9$exports, \"useField\", function () {\n  return $c796961545123cf9$export$294aa081a6c6f55d;\n});\nvar $a25d9b7703051f71$exports = {};\n$parcel$export($a25d9b7703051f71$exports, \"useLabel\", function () {\n  return $a25d9b7703051f71$export$8467354a121f1b9f;\n});\n\nfunction $a25d9b7703051f71$export$8467354a121f1b9f(props) {\n  var id = props.id,\n      label = props.label,\n      ariaLabelledby = props['aria-labelledby'],\n      ariaLabel = props['aria-label'],\n      _props$labelElementTy = props.labelElementType,\n      labelElementType = _props$labelElementTy === void 0 ? 'label' : _props$labelElementTy;\n  id = $5Odon$useId(id);\n  var labelId = $5Odon$useId();\n  var labelProps = {};\n\n  if (label) {\n    ariaLabelledby = ariaLabelledby ? ariaLabelledby + \" \" + labelId : labelId;\n    labelProps = {\n      id: labelId,\n      htmlFor: labelElementType === 'label' ? id : undefined\n    };\n  } else if (!ariaLabelledby && !ariaLabel) console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');\n\n  var fieldProps = $5Odon$useLabels({\n    id: id,\n    'aria-label': ariaLabel,\n    'aria-labelledby': ariaLabelledby\n  });\n  return {\n    labelProps: labelProps,\n    fieldProps: fieldProps\n  };\n}\n\nfunction $c796961545123cf9$export$294aa081a6c6f55d(props) {\n  var description = props.description,\n      errorMessage = props.errorMessage,\n      validationState = props.validationState;\n\n  var _$a25d9b7703051f71$ex = $a25d9b7703051f71$export$8467354a121f1b9f(props),\n      labelProps = _$a25d9b7703051f71$ex.labelProps,\n      fieldProps = _$a25d9b7703051f71$ex.fieldProps;\n\n  var descriptionId = $5Odon$useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n  var errorMessageId = $5Odon$useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n  fieldProps = $5Odon$mergeProps(fieldProps, {\n    'aria-describedby': [descriptionId, errorMessageId, props['aria-describedby']].filter(Boolean).join(' ') || undefined\n  });\n  return {\n    labelProps: labelProps,\n    fieldProps: fieldProps,\n    descriptionProps: {\n      id: descriptionId\n    },\n    errorMessageProps: {\n      id: errorMessageId\n    }\n  };\n}\n\nexport { $c796961545123cf9$export$294aa081a6c6f55d as useField, $a25d9b7703051f71$export$8467354a121f1b9f as useLabel };","map":{"version":3,"sources":["packages/@react-aria/label/src/useField.ts","packages/@react-aria/label/src/useLabel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;SCoCgB,yC,CAAS,K,EAAkC;AACzD,MACE,EADF,GAMI,KANJ,CAAK,EAAL;AAAA,MAEE,KAFF,GAMI,KANJ,CACI,KADJ;AAAA,MAGqB,cAHrB,GAMI,KANJ,CAGE,iBAHF;AAAA,MAIgB,SAJhB,GAMI,KANJ,CAIE,YAJF;AAAA,8BAMI,KANJ,CAIyB,gBAJzB;AAAA,MAKE,gBALF,sCAKqB,OALrB;AAQA,EAAA,EAAE,GAAG,YAAK,CAAC,EAAD,CAAV;AACA,MAAI,OAAO,GAAG,YAAK,EAAnB;AACA,MAAI,UAAU,GAAG,EAAjB;;AACA,MAAI,KAAJ,EAAW;AACT,IAAA,cAAc,GAAG,cAAc,GAAM,cAAN,SAAwB,OAAxB,GAAoC,OAAnE;AACA,IAAA,UAAU,GAAG;AACX,MAAA,EAAE,EAAE,OADO;AAEX,MAAA,OAAO,EAAE,gBAAgB,KAAK,OAArB,GAA+B,EAA/B,GAAoC;AAFlC,KAAb;AAID,GAND,MAMO,IAAE,CAAG,cAAH,IAAiB,CAAK,SAAxB,EACL,OAAO,CAAC,IAAR,CAAa,sHAAb;;AAGF,MAAI,UAAU,GAAG,gBAAS,CAAC;QACzB,EADyB;AAEzB,kBAAc,SAFW;AAGzB,uBAAmB;AAHM,GAAD,CAA1B;AAMA,SAAO;gBACL,UADK;gBAEL;AAFK,GAAP;AAID;;SDrCe,yC,CAAS,K,EAAkC;AACzD,MAAK,WAAL,GAAmD,KAAnD,CAAK,WAAL;AAAA,MAAkB,YAAlB,GAAmD,KAAnD,CAAgB,YAAhB;AAAA,MAAgC,eAAhC,GAAmD,KAAnD,CAA8B,eAA9B;;AACA,8BAA+B,yCAAQ,CAAC,KAAD,CAAvC;AAAA,MAAK,UAAL,yBAAK,UAAL;AAAA,MAAiB,UAAjB,yBAAe,UAAf;;AAEA,MAAI,aAAa,GAAG,gBAAS,CAAC,CAAC,OAAO,CAAC,WAAD,CAAR,EAAuB,OAAO,CAAC,YAAD,CAA9B,EAA8C,eAA9C,CAAD,CAA7B;AACA,MAAI,cAAc,GAAG,gBAAS,CAAC,CAAC,OAAO,CAAC,WAAD,CAAR,EAAuB,OAAO,CAAC,YAAD,CAA9B,EAA8C,eAA9C,CAAD,CAA9B;AAEA,EAAA,UAAU,GAAG,iBAAU,CAAC,UAAD,EAAa;AAClC,wBAAoB,CAClB,aADkB,EAGlB,cAHkB,EAIlB,KAAK,CAAC,kBAAD,CAJa,EAKlB,MALkB,CAKX,OALW,EAKF,IALE,CAKG,GALH,KAKW;AANG,GAAb,CAAvB;AASA,SAAO;gBACL,UADK;gBAEL,UAFK;AAGL,IAAA,gBAAgB,EAAE;AAChB,MAAA,EAAE,EAAE;AADY,KAHb;AAML,IAAA,iBAAiB,EAAE;AACjB,MAAA,EAAE,EAAE;AADa;AANd,GAAP;AAUD","sourcesContent":["/*\n * Copyright 2021 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 {HelpTextProps, Validation} from '@react-types/shared';\nimport {HTMLAttributes} from 'react';\nimport {LabelAria, LabelAriaProps, useLabel} from './useLabel';\nimport {mergeProps, useSlotId} from '@react-aria/utils';\n\ninterface AriaFieldProps extends LabelAriaProps, HelpTextProps, Omit<Validation, 'isRequired'> {}\n\nexport interface FieldAria extends LabelAria {\n  /** Props for the description element, if any. */\n  descriptionProps: HTMLAttributes<HTMLElement>,\n  /** Props for the error message element, if any. */\n  errorMessageProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the accessibility implementation for input fields.\n * Fields accept user input, gain context from their label, and may display a description or error message.\n * @param props - Props for the Field.\n */\nexport function useField(props: AriaFieldProps): FieldAria {\n  let {description, errorMessage, validationState} = props;\n  let {labelProps, fieldProps} = useLabel(props);\n\n  let descriptionId = useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n  let errorMessageId = useSlotId([Boolean(description), Boolean(errorMessage), validationState]);\n\n  fieldProps = mergeProps(fieldProps, {\n    'aria-describedby': [\n      descriptionId,\n      // Use aria-describedby for error message because aria-errormessage is unsupported using VoiceOver or NVDA. See https://github.com/adobe/react-spectrum/issues/1346#issuecomment-740136268\n      errorMessageId,\n      props['aria-describedby']\n    ].filter(Boolean).join(' ') || undefined\n  });\n\n  return {\n    labelProps,\n    fieldProps,\n    descriptionProps: {\n      id: descriptionId\n    },\n    errorMessageProps: {\n      id: errorMessageId\n    }\n  };\n}\n","/*\n * Copyright 2020 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 {AriaLabelingProps, DOMProps, LabelableProps} from '@react-types/shared';\nimport {ElementType, LabelHTMLAttributes} from 'react';\nimport {useId, useLabels} from '@react-aria/utils';\n\nexport interface LabelAriaProps extends LabelableProps, DOMProps, AriaLabelingProps {\n  /**\n   * The HTML element used to render the label, e.g. 'label', or 'span'.\n   * @default 'label'\n   */\n  labelElementType?: ElementType\n}\n\nexport interface LabelAria {\n  /** Props to apply to the label container element. */\n  labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n  /** Props to apply to the field container element being labeled. */\n  fieldProps: AriaLabelingProps & DOMProps\n}\n\n/**\n * Provides the accessibility implementation for labels and their associated elements.\n * Labels provide context for user inputs.\n * @param props - The props for labels and fields.\n */\nexport function useLabel(props: LabelAriaProps): LabelAria {\n  let {\n    id,\n    label,\n    'aria-labelledby': ariaLabelledby,\n    'aria-label': ariaLabel,\n    labelElementType = 'label'\n  } = props;\n\n  id = useId(id);\n  let labelId = useId();\n  let labelProps = {};\n  if (label) {\n    ariaLabelledby = ariaLabelledby ? `${ariaLabelledby} ${labelId}` : labelId;\n    labelProps = {\n      id: labelId,\n      htmlFor: labelElementType === 'label' ? id : undefined\n    };\n  } else if (!ariaLabelledby && !ariaLabel) {\n    console.warn('If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility');\n  }\n\n  let fieldProps = useLabels({\n    id,\n    'aria-label': ariaLabel,\n    'aria-labelledby': ariaLabelledby\n  });\n\n  return {\n    labelProps,\n    fieldProps\n  };\n}\n"]},"metadata":{},"sourceType":"module"}