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B;QAClB,mBAAmB;QACnB,kBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL,8BACA;YACE,qCAAqC;QACvC;QAGJ,eAAe;QACf,KAAK;OACJ;AAGP","sources":["packages/@adobe/react-spectrum/src/textfield/TextFieldBase.tsx"],"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 AlertMedium from '@spectrum-icons/ui/AlertMedium';\nimport CheckmarkMedium from '@spectrum-icons/ui/CheckmarkMedium';\nimport {classNames} from '../utils/classNames';\nimport {createFocusableRef} from '../utils/useDOMRef';\nimport {Field} from '../label/Field';\n// @ts-ignore\nimport intlMessages from '../../intl/textfield/*.json';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {PressEvents, RefObject, ValidationResult} from '@react-types/shared';\nimport React, {cloneElement, forwardRef, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, ReactElement, Ref, TextareaHTMLAttributes, useImperativeHandle, useRef} from 'react';\nimport {SpectrumTextFieldProps, TextFieldRef} from './TextField';\nimport styles from '@adobe/spectrum-css-temp/components/textfield/vars.css';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useId} from 'react-aria/useId';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ninterface TextFieldBaseProps extends Omit<SpectrumTextFieldProps, 'onChange' | 'validate'>, PressEvents, Partial<ValidationResult> {\n  wrapperChildren?: ReactElement | ReactElement[],\n  inputClassName?: string,\n  validationIconClassName?: string,\n  multiLine?: boolean,\n  labelProps?: LabelHTMLAttributes<HTMLLabelElement>,\n  inputProps: InputHTMLAttributes<HTMLInputElement> | TextareaHTMLAttributes<HTMLTextAreaElement>,\n  descriptionProps?: HTMLAttributes<HTMLElement>,\n  errorMessageProps?: HTMLAttributes<HTMLElement>,\n  inputRef?: RefObject<HTMLInputElement | HTMLTextAreaElement | null>,\n  loadingIndicator?: ReactElement,\n  isLoading?: boolean,\n  disableFocusRing?: boolean\n}\n\nexport const TextFieldBase = forwardRef(function TextFieldBase(props: TextFieldBaseProps, ref: Ref<TextFieldRef<HTMLInputElement | HTMLTextAreaElement>>) {\n  let {\n    validationState = props.isInvalid ? 'invalid' : null,\n    icon,\n    isQuiet = false,\n    isDisabled,\n    multiLine,\n    autoFocus,\n    inputClassName,\n    wrapperChildren,\n    labelProps,\n    inputProps,\n    descriptionProps,\n    errorMessageProps,\n    inputRef: userInputRef,\n    isLoading,\n    loadingIndicator,\n    validationIconClassName,\n    disableFocusRing\n  } = props;\n  let {hoverProps, isHovered} = useHover({isDisabled});\n  let domRef = useRef<HTMLDivElement>(null);\n  let defaultInputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n  let inputRef = userInputRef || defaultInputRef;\n\n  // Expose imperative interface for ref\n  useImperativeHandle(ref, () => ({\n    ...createFocusableRef(domRef, inputRef),\n    select() {\n      if (inputRef.current) {\n        inputRef.current.select();\n      }\n    },\n    getInputElement() {\n      return inputRef.current;\n    }\n  }));\n\n  let ElementType: React.ElementType = multiLine ? 'textarea' : 'input';\n  let isInvalid = validationState === 'invalid' && !isDisabled;\n\n  if (icon) {\n    let UNSAFE_className = classNames(\n      styles,\n      icon.props && (icon.props as any).UNSAFE_className,\n      'spectrum-Textfield-icon'\n    );\n\n    icon = cloneElement(icon, {\n      UNSAFE_className,\n      size: 'S'\n    } as any);\n  }\n\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/textfield');\n  let validId = useId();\n  let validationIcon = isInvalid\n    ? <AlertMedium />\n    : <CheckmarkMedium id={validId} aria-hidden aria-label={stringFormatter.format('valid')} />;\n  let validation = cloneElement(validationIcon, {\n    UNSAFE_className: classNames(\n      styles,\n      'spectrum-Textfield-validationIcon',\n      validationIconClassName\n    )\n  });\n\n  // Add validation icon IDREF to aria-describedby when validationState is valid\n  let inputPropsAriaDescribedBy = inputProps['aria-describedby'];\n  if (\n    !isInvalid && validationState === 'valid' && !isLoading && !isDisabled &&\n    (!inputPropsAriaDescribedBy || !inputPropsAriaDescribedBy.includes(validId))\n  ) {\n    inputProps['aria-describedby'] = [inputPropsAriaDescribedBy, validId].join(' ').trim();\n  }\n\n  let {focusProps, isFocusVisible} = useFocusRing({\n    isTextInput: true,\n    autoFocus\n  });\n\n  let textField = (\n    <div\n      className={\n        classNames(\n          styles,\n          'spectrum-Textfield',\n          {\n            'spectrum-Textfield--invalid': isInvalid,\n            'spectrum-Textfield--valid': validationState === 'valid' && !isDisabled,\n            'spectrum-Textfield--loadable': loadingIndicator,\n            'spectrum-Textfield--quiet': isQuiet,\n            'spectrum-Textfield--multiline': multiLine,\n            'focus-ring': !disableFocusRing && isFocusVisible\n          }\n        )\n      }>\n      <ElementType\n        {...mergeProps(inputProps, hoverProps, focusProps)}\n        ref={inputRef as any}\n        rows={multiLine ? 1 : undefined}\n        className={\n          classNames(\n            styles,\n            'spectrum-Textfield-input',\n            {\n              'spectrum-Textfield-inputIcon': icon,\n              'is-hovered': isHovered\n            },\n            inputClassName\n          )\n        } />\n      {icon}\n      {validationState && !isLoading && !isDisabled ? validation : null}\n      {isLoading && loadingIndicator}\n      {wrapperChildren}\n    </div>\n  );\n\n  return (\n    <Field\n      {...props}\n      labelProps={labelProps}\n      descriptionProps={descriptionProps}\n      errorMessageProps={errorMessageProps}\n      wrapperClassName={\n        classNames(\n          styles,\n          'spectrum-Textfield-wrapper',\n          {\n            'spectrum-Textfield-wrapper--quiet': isQuiet\n          }\n        )\n      }\n      showErrorIcon={false}\n      ref={domRef}>\n      {textField}\n    </Field>\n  );\n});\n"],"names":[],"version":3,"file":"TextFieldBase.cjs.map"}