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WAAW,WAAW,SAAS;YAC/B,YAAY,MAAM,UAAU,IAAI;YAChC,YAAY,MAAM,UAAU,IAAI;QAClC;QACA,kBAAkB;IACpB;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAElB,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACL,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,MAAM,UAAU,IAAI;QACnC,gBAAc,WAAW,SAAS,IAAI;QACtC,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;qBACnC,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAkB;aAAE;YACxD;gBAAC,CAAA,GAAA,yCAAc;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAkB;aAAE;YAC3D;gBACE,CAAA,GAAA,sCAAW;gBACX;oBACE,MAAM;oBACN,WAAW,WAAW,SAAS;oBAC/B,YAAY,MAAM,UAAU,IAAI;gBAClC;aACD;YACD;gBACE,CAAA,GAAA,qCAAU;gBACV;oBACE,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aACD;YACD;gBAAC,CAAA,GAAA,2CAAgB;gBAAG;aAAW;SAChC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/TextField.tsx"],"sourcesContent":["/*\n * Copyright 2022 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, useTextField} from 'react-aria/useTextField';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  DOMProps,\n  Provider,\n  RACValidation,\n  removeDataAttributes,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps,\n  useSlot,\n  useSlottedContext\n} from './utils';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, useCallback, useRef, useState} from 'react';\nimport {TextAreaContext} from './TextArea';\nimport {TextContext} from './Text';\n\nexport interface TextFieldRenderProps {\n  /**\n   * Whether the text field is disabled.\n   *\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean;\n  /**\n   * Whether the value is invalid.\n   *\n   * @selector [data-invalid]\n   */\n  isInvalid: boolean;\n  /**\n   * Whether the text field is read only.\n   *\n   * @selector [data-readonly]\n   */\n  isReadOnly: boolean;\n  /**\n   * Whether the text field is required.\n   *\n   * @selector [data-required]\n   */\n  isRequired: boolean;\n}\n\nexport interface TextFieldProps\n  extends\n    Omit<\n      AriaTextFieldProps,\n      | 'label'\n      | 'placeholder'\n      | 'description'\n      | 'errorMessage'\n      | 'validationState'\n      | 'validationBehavior'\n    >,\n    RACValidation,\n    Omit<DOMProps, 'style' | 'className' | 'render' | 'children'>,\n    SlotProps,\n    RenderProps<TextFieldRenderProps>,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-TextField'\n   */\n  className?: ClassNameOrFunction<TextFieldRenderProps>;\n  /** Whether the value is invalid. */\n  isInvalid?: boolean;\n}\n\nexport const TextFieldContext = createContext<ContextValue<TextFieldProps, HTMLDivElement>>(null);\n\n/**\n * A text field allows a user to enter a plain text value with a keyboard.\n */\nexport const TextField = /*#__PURE__*/ createHideableComponent(function TextField(\n  props: TextFieldProps,\n  ref: ForwardedRef<HTMLDivElement>\n) {\n  [props, ref] = useContextProps(props, ref, TextFieldContext);\n  let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n  let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n  let inputRef = useRef<HTMLInputElement>(null);\n  [props, inputRef as unknown] = useContextProps(props, inputRef, FieldInputContext);\n  let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n  let [inputElementType, setInputElementType] = useState('input');\n  let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} =\n    useTextField<any>(\n      {\n        ...removeDataAttributes(props),\n        inputElementType,\n        label,\n        validationBehavior\n      },\n      inputRef\n    );\n\n  // Intercept setting the input ref so we can determine what kind of element we have.\n  // useTextField uses this to determine what props to include.\n  let inputOrTextAreaRef = useCallback(\n    el => {\n      inputRef.current = el;\n      if (el) {\n        setInputElementType(el instanceof HTMLTextAreaElement ? 'textarea' : 'input');\n      }\n    },\n    [inputRef]\n  );\n\n  let renderProps = useRenderProps({\n    ...props,\n    values: {\n      isDisabled: props.isDisabled || false,\n      isInvalid: validation.isInvalid,\n      isReadOnly: props.isReadOnly || false,\n      isRequired: props.isRequired || false\n    },\n    defaultClassName: 'react-aria-TextField'\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n  delete DOMProps.id;\n\n  return (\n    <dom.div\n      {...DOMProps}\n      {...renderProps}\n      ref={ref}\n      slot={props.slot || undefined}\n      data-disabled={props.isDisabled || undefined}\n      data-invalid={validation.isInvalid || undefined}\n      data-readonly={props.isReadOnly || undefined}\n      data-required={props.isRequired || undefined}>\n      <Provider\n        values={[\n          [LabelContext, {...labelProps, ref: labelRef}],\n          [InputContext, {...inputProps, ref: inputOrTextAreaRef}],\n          [TextAreaContext, {...inputProps, ref: inputOrTextAreaRef}],\n          [\n            GroupContext,\n            {\n              role: 'presentation',\n              isInvalid: validation.isInvalid,\n              isDisabled: props.isDisabled || false\n            }\n          ],\n          [\n            TextContext,\n            {\n              slots: {\n                description: descriptionProps,\n                errorMessage: errorMessageProps\n              }\n            }\n          ],\n          [FieldErrorContext, validation]\n        ]}>\n        {renderProps.children}\n      </Provider>\n    </dom.div>\n  );\n});\n"],"names":[],"version":3,"file":"TextField.cjs.map"}