{"ast":null,"code":"import { useLabel } from \"@react-aria/label\";\nimport { useFocusable } from \"@react-aria/focus\";\nimport { filterDOMProps, mergeProps } from \"@react-aria/utils\";\nimport _babelRuntimeHelpersEsmExtends from \"@babel/runtime/helpers/esm/extends\";\nexport function useTextField(props, ref) {\n  var _props$inputElementTy = props.inputElementType,\n      inputElementType = _props$inputElementTy === void 0 ? 'input' : _props$inputElementTy,\n      _props$isDisabled = props.isDisabled,\n      isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,\n      _props$isRequired = props.isRequired,\n      isRequired = _props$isRequired === void 0 ? false : _props$isRequired,\n      _props$isReadOnly = props.isReadOnly,\n      isReadOnly = _props$isReadOnly === void 0 ? false : _props$isReadOnly,\n      validationState = props.validationState,\n      _props$type = props.type,\n      type = _props$type === void 0 ? 'text' : _props$type,\n      _props$onChange = props.onChange,\n      _onChange = _props$onChange === void 0 ? function () {} : _props$onChange;\n\n  var _useFocusable = useFocusable(props, ref),\n      focusableProps = _useFocusable.focusableProps;\n\n  var _useLabel = useLabel(props),\n      labelProps = _useLabel.labelProps,\n      fieldProps = _useLabel.fieldProps;\n\n  var domProps = filterDOMProps(props, {\n    labelable: true\n  });\n  var inputOnlyProps = {\n    type: type,\n    pattern: props.pattern\n  };\n  return {\n    labelProps: labelProps,\n    inputProps: mergeProps(domProps, inputElementType === 'input' && inputOnlyProps, _babelRuntimeHelpersEsmExtends({\n      disabled: isDisabled,\n      readOnly: isReadOnly,\n      'aria-required': isRequired || undefined,\n      'aria-invalid': validationState === 'invalid' || undefined,\n      'aria-errormessage': props['aria-errormessage'],\n      'aria-activedescendant': props['aria-activedescendant'],\n      'aria-autocomplete': props['aria-autocomplete'],\n      'aria-haspopup': props['aria-haspopup'],\n      value: props.value,\n      defaultValue: props.value ? undefined : props.defaultValue,\n      onChange: function onChange(e) {\n        return _onChange(e.target.value);\n      },\n      autoComplete: props.autoComplete,\n      maxLength: props.maxLength,\n      minLength: props.minLength,\n      name: props.name,\n      placeholder: props.placeholder,\n      inputMode: props.inputMode,\n      onCopy: props.onCopy,\n      onCut: props.onCut,\n      onPaste: props.onPaste,\n      onCompositionEnd: props.onCompositionEnd,\n      onCompositionStart: props.onCompositionStart,\n      onCompositionUpdate: props.onCompositionUpdate,\n      onSelect: props.onSelect,\n      onBeforeInput: props.onBeforeInput,\n      onInput: props.onInput\n    }, focusableProps, fieldProps))\n  };\n}","map":{"version":3,"sources":["packages/@react-aria/textfield/src/useTextField.ts"],"names":["inputElementType","isDisabled","isRequired","isReadOnly","type","onChange","focusableProps","useFocusable","fieldProps","useLabel","domProps","filterDOMProps","labelable","inputOnlyProps","pattern","props","labelProps","inputProps","mergeProps","disabled","readOnly","validationState","value","defaultValue","e","autoComplete","maxLength","minLength","name","placeholder","inputMode","onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onSelect","onBeforeInput","onInput"],"mappings":";;;;OAyCO,SAAA,YAAA,CAAA,KAAA,EAAA,GAAA,EAGU;AAAA,8BACf,KADe,CAEbA,gBAFa;AAAA,MAEbA,gBAFa,sCACX,OADW;AAAA,0BACf,KADe,CAGbC,UAHa;AAAA,MAGbA,UAHa,kCACX,KADW;AAAA,0BACf,KADe,CAIbC,UAJa;AAAA,MAIbA,UAJa,kCACX,KADW;AAAA,0BACf,KADe,CAKbC,UALa;AAAA,MAKbA,UALa,kCACX,KADW;AAAA,MACX,eADW,GACf,KADe,CACX,eADW;AAAA,oBACf,KADe,CAObC,IAPa;AAAA,MAObA,IAPa,4BACX,MADW;AAAA,wBACf,KADe,CAQbC,QARa;AAAA,MAQbA,SARa,gCAQF,YAAM,CAAE,CARN;;AAAA,sBAUQE,YAAY,CAAA,KAAA,EAAnC,GAAmC,CAVpB;AAAA,MAUVD,cAVU,iBAUVA,cAVU;;AAAA,kBAWgBG,QAAQ,CAAvC,KAAuC,CAXxB;AAAA,MAWX,UAXW,aAWX,UAXW;AAAA,MAWED,UAXF,aAWEA,UAXF;;AAYf,MAAIE,QAAQ,GA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AAA,MAAM,EAAEhB,KAAK,CAvBK,MAAA;AAwBlBiB,MAAAA,KAAK,EAAEjB,KAAK,CAxBM,KAAA;AAyBlBkB,MAAAA,OAAO,EAAElB,KAAK,CAzBI,OAAA;AA4BlBmB,MAAAA,gBAAgB,EAAEnB,KAAK,CA5BL,gBAAA;AA6BlBoB,MAAAA,kBAAkB,EAAEpB,KAAK,CA7BP,kBAAA;AA8BlBqB,MAAAA,mBAAmB,EAAErB,KAAK,CA9BR,mBAAA;AAiClBsB,MAAAA,QAAQ,EAAEtB,KAAK,CAjCG,QAAA;AAoClBuB,MAAAA,aAAa,EAAEvB,KAAK,CApCF,aAAA;AAqClBwB,MAAAA,OAAO,EAAExB,KAAK,CAACwB;AArCG,KAAA,EAAA,cAAA,EAAA,UAAA,CAAA;AAFjB,GAAP;AA6CD","sourcesContent":["/*\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 {AriaTextFieldProps} from '@react-types/textfield';\nimport {ChangeEvent, InputHTMLAttributes, LabelHTMLAttributes, RefObject, TextareaHTMLAttributes} from 'react';\nimport {ElementType} from 'react';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {useLabel} from '@react-aria/label';\n\ninterface TextFieldAria {\n  /** Props for the input element. */\n  inputProps: InputHTMLAttributes<HTMLInputElement> | TextareaHTMLAttributes<HTMLTextAreaElement>,\n  /** Props for the text field's visible label element (if any). */\n  labelProps: LabelHTMLAttributes<HTMLLabelElement>\n}\n\ninterface AriaTextFieldOptions extends AriaTextFieldProps {\n  /**\n   * The HTML element used to render the input, e.g. 'input', or 'textarea'.\n   * It determines whether certain HTML attributes will be included in `inputProps`.\n   * For example, [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type).\n   * @default 'input'\n   */\n  inputElementType?: ElementType\n}\n\n/**\n * Provides the behavior and accessibility implementation for a text field.\n * @param props - Props for the text field.\n * @param ref - Ref to the HTML input or textarea element.\n */\nexport function useTextField(\n  props: AriaTextFieldOptions,\n  ref: RefObject<HTMLInputElement | HTMLTextAreaElement>\n): TextFieldAria {\n  let {\n    inputElementType = 'input',\n    isDisabled = false,\n    isRequired = false,\n    isReadOnly = false,\n    validationState,\n    type = 'text',\n    onChange = () => {}\n  } = props;\n  let {focusableProps} = useFocusable(props, ref);\n  let {labelProps, fieldProps} = useLabel(props);\n  let domProps = filterDOMProps(props, {labelable: true});\n\n  const inputOnlyProps = {\n    type,\n    pattern: props.pattern\n  };\n\n  return {\n    labelProps,\n    inputProps: mergeProps(\n      domProps,\n      inputElementType === 'input' && inputOnlyProps,\n      {\n        disabled: isDisabled,\n        readOnly: isReadOnly,\n        'aria-required': isRequired || undefined,\n        'aria-invalid': validationState === 'invalid' || undefined,\n        'aria-errormessage': props['aria-errormessage'],\n        'aria-activedescendant': props['aria-activedescendant'],\n        'aria-autocomplete': props['aria-autocomplete'],\n        'aria-haspopup': props['aria-haspopup'],\n        value: props.value,\n        defaultValue: props.value ? undefined : props.defaultValue,\n        onChange: (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value),\n        autoComplete: props.autoComplete,\n        maxLength: props.maxLength,\n        minLength: props.minLength,\n        name: props.name,\n        placeholder: props.placeholder,\n        inputMode: props.inputMode,\n\n        // Clipboard events\n        onCopy: props.onCopy,\n        onCut: props.onCut,\n        onPaste: props.onPaste,\n\n        // Composition events\n        onCompositionEnd: props.onCompositionEnd,\n        onCompositionStart: props.onCompositionStart,\n        onCompositionUpdate: props.onCompositionUpdate,\n\n        // Selection events\n        onSelect: props.onSelect,\n\n        // Input events\n        onBeforeInput: props.onBeforeInput,\n        onInput: props.onInput,\n        ...focusableProps,\n        ...fieldProps\n      }\n    )\n  };\n}\n"]},"metadata":{},"sourceType":"module"}